$(document).ready(function() {
$('#btnSubmit').click(function(e) {
//btnSubmit is button id
//For all text boxes "text"
var isValid = true;
$('input[type="text"]').each(function() {
if ($.trim($(this).val()) == '') {
isValid = false;
$(this).css({
"border": "1px solid red",
"background": "#FFCECE"
});
}
else {
$(this).css({
"border": "",
"background": ""
});
}
});
if (isValid == false)
e.preventDefault();
else
alert('Thank you for submitting');
});
//for all validations are completed or not condition isvalid
});
Comments
Post a Comment