File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript validation in PHP

 
bala kan
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am doing a login page which contains user name and password..

I need to validate the username using regular expression
the criteria is as follows:
1)It can contain either alphabets, special characters(-,'',_) or numbers..
2)length should be minimum of 8 characters and maximum of 20 characters..

so, my codings to validate the username is




"if(!(/^[a-zA-Z0-9/-_ ]{8,20}$/).test(uid))" does not validate the above mentioned criteria.. please clarify me

Thanks in advance

Regards,
Bala


 
Nick Charles
Ranch Hand
Posts: 71
Linux PHP Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that the '/' after '9' is terminating the regular expression. I think you meant to use a '\'.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic