View Full Version : validate form (some fields)

06-18-2007, 03:05 AM
how i can validate a form.

if $pass is more than 5 characters return an alert message. Same function for white spaces in $pass and $username fields.

Regards friends.

Philip M
06-18-2007, 08:47 AM
A variable name in JavaScript may only start with a letter, not a number or a $ sign.

if (password.length > 5) {
alert ("The maximum length is 5 characters);

If you want to delete spaces in a variable then:

password = password.replace(/\s/g, "");