How to check whether an HTML form variable exists
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Wednesday, January 14, 2004 09:12 PM

Hello. I have an HTML form. Sometimes the form field "comments" is declared -

			


Sometimes there is no declaration and the field "comments" doesn't exist. Using Javascript how can I test whether the form field "comments" was created in the form. I'm NOT asking how to check that a value has been entered into the comments field but rather that the field was created.


Any help would be greatly appreciated!!!


Thank you!


Tiffany

Re: How to check whether an HTML form variable exists

Posted By:   Alexandre_Jacques  
Posted On:   Sunday, February 15, 2004 05:13 AM

Tiffany,


call this one in a javascript function where you should check the existence of the field.



if(document.forms[0].comments!=null) {
//... do some stuff
}

hope it helps,

regards,


alexandre jacques

Re: How to check whether an HTML form variable exists

Posted By:   Firat_Tiryaki  
Posted On:   Thursday, January 15, 2004 02:09 AM

just check if it's null or not



if(document.formName.comments==null){
//comments doesn't exist do what you want to do
}
else{
//comments exists here
}
About | Sitemap | Contact