hi ,
i am in a fix . i have a text box that by id company name. when the user enters numbers how do i restrict him from entering numbers. can anyone tell me how to do this using javascript.
thanks,
abhiram.
Printable View
hi ,
i am in a fix . i have a text box that by id company name. when the user enters numbers how do i restrict him from entering numbers. can anyone tell me how to do this using javascript.
thanks,
abhiram.
Have just found this on the net (won't take the credit for this code as it's from www.webreference.com):
The field's event handler would be configured like the following:Code:function numeralsOnly(evt) {
evt = (evt) ? evt : event;
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
((evt.which) ? evt.which : 0));
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
alert("Enter numerals only in this field.");
return false;
}
return true;
}
Code:onkeypress="return numeralsOnly(event)"