// Java Script Code
[script]
function OnlyDig(val)
{
var exp = /[^\d]/g;
//The variable exp is the regular expression for digits only."[^\d]" means that all characters of keyboard except digits."/g" is used to validate all occurrences in a textbox.
//alert("digit only");
var a=val.value;
if ( a.match( exp ) )
alert("digit only");
val.value = val.value.replace(exp,'');
}
[/script]
// HTML LINE
[input type="text" name="txt" id="txtid" onkeyup="OnlyDig(this)" /]
No comments:
Post a Comment