permaculture playing cards*
The moose likes PHP and the fly likes Javascript validation in PHP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » PHP
Bookmark "Javascript validation in PHP" Watch "Javascript validation in PHP" New topic
Author

Javascript validation in PHP

bala kan
Ranch Hand

Joined: Aug 20, 2012
Posts: 44
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

Joined: Oct 09, 2011
Posts: 71

My guess is that the '/' after '9' is terminating the regular expression. I think you meant to use a '\'.
 
 
subject: Javascript validation in PHP
 
Similar Threads
simple struts2 validation needed on my action class
Problem Passing Parameter values to action
How to submit form with return
cookie and login
javascript not working