Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JS Form Validation Question

Status
Not open for further replies.

OrangeWire

IS-IT--Management
Mar 26, 2003
28
US
the current source i have looks like this:
var field = form.name;
var name = parseInt(field.value);
if (!name) {
alert("Please enter your name.");
return false;
} else if ...... etc etc

i have a bunch of fields on this page that i need to validate and i would like to SKIP the first line...

is it possible for me to do something like this:

var name = parseInt(form.name.value); ?

Thanks a lot guys!

 
If you're just trying to make sure that info was entered...

Code:
function checkForm(){
 theForm = document.myForm
 msg = ""
 for (x=0; x<theForm.elements.length; x++){
   if (theForm.elements[x].type == "text"){
     if (theForm.elements[x].value == ""){
       msg += "\n-" + theForm.elements[x].name
     }
   }
 }
 if (msg != ""){
   alert("Please fill in the following:\n" + msg)
   return false
 }
 return true
}

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top