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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Form Validation 1

Status
Not open for further replies.

kevcold

MIS
Apr 19, 2001
15
0
0
US
Need help with a form validation. Form have 8 fields (text input tags>, user must fill in at least "2" fields before proceeding. Form is input criteria for a data retrieval. I just want to do a client side verification that at least 2 fields have been populated.
Thanks in advance,
KevCold
 
Say you have 8 text fields with the same name, text1

var z, valid;
z = 0;
valid = false;

for (var x=0; x<document.form_name.text1.length; x++){
if (document.form_name.text1[x].value != &quot;&quot;)
z++;

if (z == 2){
valid = true;
break;
}
}
------------------
Freedom is a Right
 
Thanks goatstudio! That's what I was looking for. I kept trying to build an array and verify with reg exp - didn't work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top