[thelist] javascript form validation help
EvoltList at no-pun.com
EvoltList at no-pun.com
Wed Jun 11 11:56:48 CDT 2008
Okay, I suck at javascript (VB script, no problem). Apparently, of the many
times I've written form validation, I never had to deal with radio buttons
as conditionals. Could use some code help here. Form ref:
https://shop.wamalaw.com/Inc_Form.asp
I have a couple radio button groups wherein if one button is checked,
validation then is required for associated form fields. I have included my
_incorrect_ approach within, just so you see what I am trying to accomplish.
<script language="javaScript" type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false;}
else {return true;}
}
}
function validate_form(thisform) {
with (thisform)
{
if (validate_required(PaymentCode,"Enter your payment code from email
confirmation.")==false)
{PaymentCode.focus();return false;}
' radion button: incorrect code below. Field names *Option are the radio
buttons; others are input fields
if (validate_required(FNOption,"Select whether you wish us to register
fictitious name.")==false)
{FNOption.focus();return false;}
if (FNOption.value == "y") {
if (validate_required(FN,"Enter a fictitious name.")==false)
{FN.focus();return false;}
}
if (validate_required(AddressOption,"Select whether you wish to use our
physical address for incorporation.")==false)
{AddressOption.focus();return false;}
if (AddressOption.value == "n") {
if (validate_required(Street1,"Enter Florida physical address street of
corporation's principal office.")==false)
{Street1.focus();return false;}
if (validate_required(City,"Enter Florida address city of corporation's
principal office.")==false)
{City.focus();return false;}
if (validate_required(Zip,"Enter Florida address ZIP code of
corporation's principal office.")==false)
{Zip.focus();return false;}
if (validate_required(County,"Enter Florida county corporation's
principal office.")==false)
{County.focus();return false;}
}
}
}
</script>
Merci beaucoup!
Greta
More information about the thelist
mailing list