I'm using the following to make sure fields aren't empty before they get posted in jquery:
if(this.field.value == "") {
jQuery( ".page-error-message" ).remove();
jQuery(".top").append(jQuery("field required"));
jQuery('html, body').animate({ scrollTop: 0 }, 'slow');
return;
}
I have some radio buttons that need yes selected, however it doesn't seem to work if I do say:
if(this.radiobutton.value == "no") {
jQuery( ".page-error-message" ).remove();
jQuery(".top").append(jQuery("field must be yes"));
jQuery('html, body').animate({ scrollTop: 0 }, 'slow');
return;
}
What am I doing wrong?
Radio buttons have multiple fields. You're better checking that the no button is checked.
eg;
if(this.radiobutton.checked) {
jQuery( ".page-error-message" ).remove();
jQuery(".top").append(jQuery("field must be yes"));
jQuery('html, body').animate({ scrollTop: 0 }, 'slow');
return;
}
Where radiobutton is the radio button with a value of no.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With