<script>
function ValidateNumber(e) {
var evt = (e) ? e : window.event;
var charCode = (evt.keyCode) ? evt.keyCode : evt.which;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
};
</script>
And to call the function in the text box
@Html.TextBoxFor(model => model.Vendor.Mobile, new { @class = "form-control", @maxlength = "10",onkeydown="return ValidateNumber(event);"})
function ValidateNumber(e) {
var evt = (e) ? e : window.event;
var charCode = (evt.keyCode) ? evt.keyCode : evt.which;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
};
</script>
And to call the function in the text box
@Html.TextBoxFor(model => model.Vendor.Mobile, new { @class = "form-control", @maxlength = "10",onkeydown="return ValidateNumber(event);"})
No comments:
Post a Comment