/ Published in: PHP
                    
                                        
Validates Numericals in a text box.
Validates spaces in a text box.
                Validates spaces in a text box.
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
<script language=Javascript>
function isSpaceKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if ((charCode == 32))
{
alert("Spaces are not allowed");
return true;
}
else ((charCode >= 47 && charCode <= 58))
{
alert("Numerics are not allowed");
return true;
}
return true;
}
</script>
<script language=Javascript>
function isAlphaKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if ((charCode >= 47 && charCode <= 58))
{
alert("Enter Numeric Values");
return true;
}
return true;
}
</script>
URL: http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
Comments
 Subscribe to comments
                    Subscribe to comments
                
                