I'm having issues with Javascript form validation for radio and checkboxes.
I have a external .js script with all my function rules linked in the html head section.
My rules look like this for example:
function IsValid4DigitZip( str ) {
// Return immediately if an invalid value was passed in
if (str+"" == "undefined" || str+"" == "null" || str+"" == "")
return false;
var isValid = true;
str += "";
// Rules: zipstr must be 5 characters long, and can only contain numbers from
// 0 through 9
if (IsBlank(str) || (str.length != 4) || !IsInt(str, false))
isValid = false;
return isValid;
} // end IsValid4DigitZip
And I call the function the section like this:
if (IsValid4DigitZip(document.orderbooks.querySelectorAll("[name=postcode]")[0].value)) {
} else {
alert("Invalid postcode: You entered 3 or less digits. Please enter a 4 digit postcode");
return false;
}
Can some one help write function rules for radio and checkboxes using my examples.
I can only use Javascript. No Jquery.
Thank you.