Form Validation

Results 1 to 2 of 2

Thread: Form Validation

  1. #1
    Join Date
    Dec 1969

    Default Form Validation

    All my other validation works except this one and it is in the same function, I just cant seem to get it to work.<BR><BR> if (!isNumeric(document.forms[0].zip.value)) {<BR> alert("Zip code must be numeric.");<BR> isValid = false;<BR> return false;<BR> }

  2. #2
    Join Date
    Dec 1969

    Default isNumeric is not JS...

    Unless you have written you own isNumeric function, that&#039;s your problem, as JavaScript doesn&#039;t have that function built in the way VBScript does.<BR><BR>Did you try:<BR><BR>if ( isNaN( parseInt( document.forms[0].zip.value ) ) ) ...<BR><BR>???<BR><BR>Why does everybody use document.forms[0] instead of document.FormName???<BR><BR>Using forms[0] means that JS has to find the zero element of the forms array instead of going directly to the FormName reference. Okay, it&#039;s probably 3 microseconds slower. No big deal, especially on a client machine. But why do it when the code isn&#039;t as clear as using the name of the form???<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts