How can i perform this jquery validation with input type button ? when i switch to input type submit it's working, but i don wan input type submit because submit button will always reload my screen with modernizr.custom.js UI. Please help, thanks.
<script src="js/modernizr.custom.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('#submit').click(function (e) {
var isValid = true;
$('#VEHNO').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();
});
});
</script>
html
<input type="text" class="input-name" id="VEHNO" name="VEHNO" type="text" />
<input type="button" value="Submit" name="submit"/>
Enterkey.