Key Down Events
-----------------
<script type="text/javascript">
$(document).ready(function () {
$("#<%= txtcontactno.ClientID%>").keydown(function (e) {
if (e.shiftKey)
e.preventDefault();
else {
var nKeyCode = e.keyCode;
//Ignore Backspace and Tab keys
if (nKeyCode == 8 || nKeyCode == 9)
return;
if (nKeyCode < 95) {
if (nKeyCode < 48 || nKeyCode > 57)
e.preventDefault();
}
else {
if (nKeyCode < 96 || nKeyCode > 105)
e.preventDefault();
}
}
});
});
</script>
Key press Events
-----------------
<script type="text/javascript">
$(document).ready(function () {
//called when key is pressed in textbox
$('#<%=txtcontactno.ClientID%>').keypress(function (e) {
alert('hello');
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
// alert('Please Enter ');
// $("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
});
</script>
------------
-----------------
<script type="text/javascript">
$(document).ready(function () {
$("#<%= txtcontactno.ClientID%>").keydown(function (e) {
if (e.shiftKey)
e.preventDefault();
else {
var nKeyCode = e.keyCode;
//Ignore Backspace and Tab keys
if (nKeyCode == 8 || nKeyCode == 9)
return;
if (nKeyCode < 95) {
if (nKeyCode < 48 || nKeyCode > 57)
e.preventDefault();
}
else {
if (nKeyCode < 96 || nKeyCode > 105)
e.preventDefault();
}
}
});
});
</script>
Key press Events
-----------------
<script type="text/javascript">
$(document).ready(function () {
//called when key is pressed in textbox
$('#<%=txtcontactno.ClientID%>').keypress(function (e) {
alert('hello');
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
// alert('Please Enter ');
// $("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
});
</script>
------------
No comments:
Post a Comment