This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validation

 
Saurabh Naik
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
How to make validation for allowing only numbers. suppose in my form there is field named phone no. so numbers should be allowed in it and not text.
so is there any built in function in java script ? or how to make use of regex in this case .
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many examples online. Have you tried searching yet?

A quick search showed me a regular expression in JavaScript for zip code. Phone numbers are similar - logic varies by region though.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Start here for regex basics.



As Jeanne pointed out, phone number varies in region-wise , code your regex pattern and test() like the code above.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic