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

Javascript validation in PHP

 
bala kan
Ranch Hand
Posts: 44
  • 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
  • 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 '\'.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic