October 14, 2006

Validating a user defined password with reg exp

A nice little reg exp from the ColdFusion Cookbook when you need to make sure a users new password (which they are setting) contains at least 1 letter and 1 number.

You can also make sure the password length is within a range, the following makes sure the password is between 6 and 15 characters long.

<cfif NOT reFind("^[[:alnum:]]{6,15}$", form.sPassword) />

Don’t you just love regular expressions :)

© Michael Sharman 2017