How to restrict digit & decimal


<script language="javascript" type="text/javascript">
function isNumberKey(evt){
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57))
return false;
return true;
}

function isNumberKeyWithDecimal(evt){
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode != 46 &amp;&amp; charCode &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57))
return false;
return true;
}
</script>
onkeypress="return isNumberKey(event)"
onkeypress="return isNumberKeyWithDecimal(event)"
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s