Allow only numbers using JavaScript for textboxes -
this question has answer here:
- how allow alpha numeric chars javascript 2 answers
i new javascript. have created form submits details database. have different textboxes, need accept only letters , allow numbers.
i got code while doing research, code tells me of invalid pattern. can me code allows only letters. tried modify code takes letters failed.
function f_check_lett(form){ //only letters , numbers allowed var text = form.bucketname.value; alert(text); var filter = /^[a-za-z0-9]+$/; if (filter.test(text)) { form.submit(); } else { form.bucketname.select(); alert("only allow letters , numbers!"); } }
use filter
var filter = /^[a-za-z]+$/;
in filter [a-za-z0-9]
accept character of: 'a' 'z', 'a' 'z', '0' '9'
since need letters, remove 0-9
filter.
Comments
Post a Comment