I am using this script to see if a user has left any inputs invalid clientside.
$('#login_submit').click(function() {
var login_email = $('#login_email').val();
var login_password = $('login_password').val();
if (login_email.length == 0) {
$('#login_email').css('background', 'red');
}
if (login_password.length == 0) {
$('#login_password').css('background', 'red');
}
});
One thing I cannot work out is how to stop the form submitting as it would. I have tried return false; but this then makes the input fields backgrounds just flicker red.
Regards,
Fiddle demo: http://jsfiddle.net/xjNut/
Just make sure you don’t have an
inputwithname="submit"in the form. All other attributes are fine to have in the input.