In order to insert only numeric value from textbox this JavaScript code could be applied.
Same code can be modified to restrict the users to enter different keyboard inputs as per requirement.
This can be done by changing the ASCII value mentioned in the JavaScript file.
JAVASCRIPT CODE:
write this function under the JavaScript code.
function isNumber(event)
{
var KeyBoardCode = (event.which) ? event.which : event.keyCode;
if (KeyBoardCode > 31 && (KeyBoardCode < 48 || KeyBoardCode > 57))
{
return false;
}
return true;
}
HTML CODE:
use this code in the textbox field to perform the required operation.
onkeypress="return isNumber(event)"
One can make the text box readonly and nothing can be pasted into that by adding the following script in textbox:
Same code can be modified to restrict the users to enter different keyboard inputs as per requirement.
This can be done by changing the ASCII value mentioned in the JavaScript file.
JAVASCRIPT CODE:
write this function under the JavaScript code.
function isNumber(event)
{
var KeyBoardCode = (event.which) ? event.which : event.keyCode;
if (KeyBoardCode > 31 && (KeyBoardCode < 48 || KeyBoardCode > 57))
{
return false;
}
return true;
}
HTML CODE:
use this code in the textbox field to perform the required operation.
onkeypress="return isNumber(event)"
One can make the text box readonly and nothing can be pasted into that by adding the following script in textbox:
onKeyPress = "javascript: return false;" onPaste = "javascript: return false;"
No comments:
Post a Comment