I have multiple input fields on my page. I Regex them with a css red border when invalid data is entered.
I want to simply check ALL input fields at once for that class before inserting data to DB. The following was my idea but fails.
if($('input').css("border") == "2px solid red"){//1 or more red borders to flag
alert('yes');
}else{
alert('no'); // there are no red borders in all inputs
}
I wouldn’t check your CSS class…
Re-run your validation function prior to submitting. Use that to check if everything is good. Also, don’t forget to validate server-side as well!