Javascript
<script type="text/javascript">
function numberOnlyExample() {
if ((event.keyCode < 48) || (event.keyCode > 57))
return false;
}
</script>
<asp:TextBox ID="TextBox1" onKeyPress="return validateNumbersOnly();"runat="server"></asp:TextBox>
Jquery
<script type="text/javascript">
$(document).ready(function () {
$('input[numeric]').keyup(function () {
var d = $(this).attr('numeric');
var val = $(this).val();
var orignalValue = val;
val = val.replace(/[0-9]*/g, "");
var msg = "Only Integer Values allowed.";
if (val != '') {
orignalValue = orignalValue.replace(/([^0-9].*)/g, "")
$(this).val(orignalValue);
alert(msg);
}
});
});
</script>
<script type="text/javascript">
$(document).ready(function () {
$('#<%=txtboxId.ClientID %>').ariyValidate({
type: "price",
error_message: ""
});
});
</script>
using javascript regular expression also we can do that. using regular expression also we can this...http://aspnettutorialonline.blogspot.com/2012/05/textbox-numeric-validation-using-javascript.html
ReplyDelete