All Forums >> [Scripting] >> ASP >> Javascript validation for ASP form fields - HELP! Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
I am making a Javascript for validating some form fields on an ASP page.
I am having trouble with the red text below. What i want it to do is check to see if either of the two radio buttons (Payroll) are checked. If not, then flg==2 alarts them to fill out pernr text field. Then, if the first radio button is checked, then I need to have them fill out a text field called pernr.
<script ID="clientEventHandlersJS" LANGUAGE="javascript"> function val() { flg=0; if (document.form1.Year.selectedIndex == ""){flg=1;} if (document.form1.Year.selectedIndex == "Select one:"){flg=1;} if (document.form1.fName.value == ""){flg=1;} if (document.form1.lName.value == ""){flg=1;} if (document.form1.SSN.value == ""){flg=1;} if (!document.form1.Payroll[0].checked && !document.form1.Payroll[1].checked){flg=1;} if (!document.form1.Payroll[0].checked && document.form1.pernr.value == ""){flg=2;} if (flg==1){ alert("All required fields need to be filled in") if (flg==2){ alert("Because you selected Regular Payroll, you must enter your Personnel Number."); }else{ document.form1.submit(); } } </script>