I am using this in one of my asp.net mvc 3 views :
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('.YesNoNotApplicable').change(function () {
if ($(this).val() === '2') {
$(this).closest('td').next('td').find('input').show();
}
else {
$(this).closest('td').next('td').find('input').hide();
}
});
$('#submitDocument').click(function () {
if ($(".checkString16").val().length > 16) {
alert("The text can be up to 16 symbols");
return false;
}
else if (!$.isNumeric($(".checkULong").val())) {
alert("Insert integer");
return false;
}
else if (!$(".checkFloat").val().match('^[0-9]*\.[0-9]*$')) {
alert("Insert float");
return false;
}
return true;
});
});
</script>
The problem here is that I get very random results. If my integer check is uncommented like now I get the integer alert all the time. If I comment it then sometimes the float check works, sometimes now, and if it works the first time, then I get the error constantly even though I have changed the value to float.