Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

help with javascript required field validation


Guest

Recommended Posts

i have this script that is trying to check if a radio box is selected if so then the user is required to type in and input box. if the multipickup is selected and the user doesn't enter a pickupname or pickup email then it should throw an alert or if pseudopickup is selected it should also throw the same alert.

 

' if (shipping_value != null) {'."\n".

' index = ((shipping_value.indexOf("multipickup")) || (shipping_value.indexOf("pseudopickup"))) ;'."\n".

' if(index >= 0 ){'."\n".

' if (document.getElementById("pickupname").value == "") {'."\n".

' alert ("Please provide Recepient\'s First and Last Name ");'."\n".

' document.getElementById("pickupname").focus();'."\n".

' error = 2;'."\n".

' return false;'."\n".

' }'."\n".

' if (document.getElementById("pickupemail").value == "") {'."\n".

' alert ("Please provide Recepient\'s Email Address");'."\n".

' document.getElementById("pickupemail").focus();'."\n".

' error = 2;'."\n".

' return false;'."\n".

' }'."\n".

' if(error != 2 && document.getElementById("pickupemail").value.indexOf("@") <= 0) {'."\n".

' alert ("Please provide a valid Recepient\'s Email Address");'."\n".

' document.getElementById("pickupemail").focus();'."\n".

' error = 2;'."\n".

' return false;'."\n".

' }'."\n".

' }'."\n".

' }'."\n".

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...