Trouble with form validation

Results 1 to 2 of 2

Thread: Trouble with form validation

  1. #1
    Join Date
    Dec 1969

    Default Trouble with form validation

    My problem is that I cannot get the form to submit??? or vaidate<BR><BR>Here is my code:<BR><BR>&#060;SCRIPT LANGUAGE="Javascript"&#062;<BR><BR>&#060;!--<BR>function CheckForm()<BR>{<BR> var error;<BR> var validphone<BR> error = false;<BR> <BR>{<BR> var radioValue = null;<BR> for (var i=0; i &#060; collectinfo.length; i++)<BR> {<BR> <BR> if (Collectinfo[i].checked) {<BR> radioValue = collectinfo[i].value;<BR> break;<BR> }<BR> }<BR> }<BR> <BR> <BR><BR> <BR> if (document.CollectInfo.txtgiven.value == "")<BR> {<BR> alert("You must enter a first name.");<BR> document.CollectInfo.txtgiven.focus();<BR> error=true;<BR> }<BR> <BR> <BR> <BR> if(document.CollectInfo.txtfamily.value=="" && error == false)<BR> {<BR> alert("You must enter a last name.");<BR> document.CollectInfo.txtfamily.focus();<BR> error=true;<BR> }<BR> <BR><BR> <BR> if(document.CollectInfo.txtcity.value=="" && error == false)<BR> {<BR> alert("You must enter a city/town/rural route");<BR> document.CollectInfo.txtcity.focus();<BR> error = true;<BR> }<BR><BR> <BR> var txtstate = document.CollectInfo.txtstate.selectedIndex;<BR> if((document.CollectInfo.txtstate[prov].value==""&#124&#124(document.CollectInfo.txtstate[prov].value == 0)) && error == false)<BR> {<BR> alert("You must choose a province or state.")<BR> document.CollectInfo.txtstate.focus();<BR> error=true;<BR> }<BR> <BR> <BR> <BR> if(document.CollectInfo.txtCardNumber.value == "" && error == false)<BR> {<BR> alert("You must enter a credit card number.");<BR> document.CollectInfo.txtCardNumber.focus();<BR> error = true;<BR> }<BR> <BR> else<BR> <BR> {<BR> error = CheckCreditCard(document.CollectInfo.txtCardNumber .value);<BR> if (error == true)<BR> document.CollectInfo.txtCardNumber.focus();<BR> }<BR> <BR> <BR> <BR> if(document.CollectInfo.txtcardmonth.value == "" && error ==false)<BR> {<BR> alert("You must enter a valid expiry month for your credit card.");<BR> document.CollectInfo.txtcardmonth.focus();<BR> error = true;<BR> }<BR> <BR> <BR> <BR> if(document.CollectInfo.txtcardyear.value == "" && error ==false)<BR> {<BR> alert("You must enter a valid expiry year for your credit card.");<BR> document.CollectInfo.txtcardyear.focus();<BR> error = true;<BR> }<BR> <BR> <BR> <BR> if (radioValue == null) <BR> {<BR> error += "Please select a select if you AGREE or DISAGREE.
    ";<BR> } <BR> <BR> if (error==false)<BR> {<BR> document.CollectInfo.action = &#060;% = "sjnb6-1.asp?R=" & random1 & "&F=" & port & "&T=" & crossingtime %&#062;;<BR> document.CollectInfo.submit();<BR> }<BR>}<BR><BR>//--&#062;<BR><BR>&#060;/SCRIPT&#062;<BR>

  2. #2
    Join Date
    Dec 1969

    Default Make up your mind...

    for (var i=0; i &#060; collectinfo.length; i++)<BR>if (Collectinfo[i].checked) {<BR>if (document.CollectInfo.txtgiven.value == "")<BR><BR>You spelled the same thing three different ways. Which is it???<BR><BR>JavaScript is *case sensitive*. It *does* care about C vs. c and i vs. I !!<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