sunnynosid
02-22-2012, 05:07 PM
I am trying to get an alert when user type a digit in my textbox and i made this code:
<script type=text/javascript>
<!--
function allowed(){
var str=document.getElementById('firstname').value;
var patt=/[0-9]/g;
if(patt.test(str)){alert(not allowed);};
}
//-->
</script>
<body>
<input type=text id=firstname />
<input type=button value=Submit onclick="allowed();" />
</body>
But when i click the button then nothing happen. Please help me. Thanks.
<script type=text/javascript>
<!--
function allowed(){
var str=document.getElementById('firstname').value;
var patt=/[0-9]/g;
if(patt.test(str)){alert(not allowed);};
}
//-->
</script>
<body>
<input type=text id=firstname />
<input type=button value=Submit onclick="allowed();" />
</body>
But when i click the button then nothing happen. Please help me. Thanks.