Jump to content

How do I check the input field arrays


Darghon

Recommended Posts

I have a form with several tabs, the tabs are all identical but represent data from different environments.

so the text fields have names like date_approved[16] representing the date_approved for environment 16.

 

Now I want to generate input checks for all tabs, so I generate checks like the following, but they don't work, any solutions?

 

//frm is a passed variable that contains the document.form
if(frm.prod_apprby[16].value != "" && frm.prod_dtappr[16].value == ""){
			alert("Env 16: Production Approved by can not be filled in if date approved is blank.");
			return false;
		}

 

Thx in advance

Link to comment
Share on other sites

document.form was not what frm stood for,

 

to be more detailed, frm was => document.frmRequest

so frm.prod_apprby[16] was => document.frmRequest.prod_apprby[16]

where "prod_apprby[16]" was the name of a field in the form

 

I managed to solve this with the following statement:

 

document.getElementsByName("prod_apprby[16]")[0].value

 

This would give me the value of that field, and not an undefined error like the previous attempt did.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.