0

I"m building a registration form, and I need to validate the user's inputs. (username, email, password).

I have regular expressions set up for each of these, and I can easily validate each in PHP using preg_match, and if it returns false, I can display an error.

However, I think it'd be much nicer if the page did not have to refresh to display the error. Is there a javascript/ jQuery equivalent of preg_match?

Thanks in advance for the help! I really appreciate it.

(PS, I've seen the jQuery "validate" plugin, but I'd much prefer to do it myself)

KatieK
  • 13,586
  • 17
  • 76
  • 90
Giles Van Gruisen
  • 961
  • 3
  • 13
  • 27

2 Answers2

3

Sure here is ref: from w3cscools

Eldar Djafarov
  • 23,327
  • 2
  • 33
  • 27
0

Yes - match is native to JavaScript. It will match a string against a regular expression.

(See Regular expression field validation in jQuery for an example of matching inside jQuery.)

Community
  • 1
  • 1
KatieK
  • 13,586
  • 17
  • 76
  • 90