Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validation check phone field

 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i check the textbox only contain numeric ,not letter such as phone no field in javascript
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15484
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use regular expressions for this.

Googling for javascript phone number validation gives some links that look interesting.

(Note: JavaScript doesn't have anything to do with Java. We do have a forum about HTML and JavaScript here, so I've moved your question there for you).
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regular expressions would be one way. But be aware that many people enter phone numbers containing characters such as + / - ( ) or . - you need to account for that in some way. Or you can just remove everything that is not a number after they've entered it. Of course, "+491234567890" is not the same phone number as "491234567890", just in case you need to handle international numbers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic