Validating to accept both number and char but needing at least 2 digits

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Nov 2008
Posts: 42
Reputation: squarkman is an unknown quantity at this point 
Solved Threads: 0
squarkman squarkman is offline Offline
Light Poster

Re: Validating to accept both number and char but needing at least 2 digits

 
0
  #11
Dec 18th, 2008
/(/([\d]{2,10}[\w][/s])|([\w][\d]{2,10}[/s])|([\w][\d]{2,10}[\w][/s])|[\d]{2,10}[\w]|([\w][\d]{2,10})|([\w][\d]{2,10}[\w])/

or would I have to specify without white spaces too? This epxression could get really long depending on how complicated your requirements are, yes?
Thx
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Validating to accept both number and char but needing at least 2 digits

 
0
  #12
Dec 18th, 2008
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 106
Reputation: sid78669 is an unknown quantity at this point 
Solved Threads: 4
sid78669's Avatar
sid78669 sid78669 is offline Offline
Junior Poster

Re: Validating to accept both number and char but needing at least 2 digits

 
0
  #13
Dec 19th, 2008
id say skip regular expressions as if your strin gis actually very long, its going to be quite a big expression. Also, you will not be able to count how many of the entered digits are numbers. Unless, you specify to the user where they need to put the numbers that is at the start or at the end, or something, regular wont do such a good job. Stick with a for loop and try to just count the number of occurances of numbers to be more than two. that should be sufficient to suit your need.
Live free.... Die Hard!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC