I'm having a couple of issues with my form.
1. I need a regular expression that allows only alpha chars for a name field. My regular expression is allowing this (John D##). Also my expression isn't allowing spaces between first and last names like this (John Doe).
2. My form is suppose to make sure that a city is selected from the drop down menu. Here's my code for that:Code:function checkIllegalChars(theuser_name, error){ var name_exp = /[a-zA-Z]+/; for(var i=0; i < theuser_name.length; i++) { the_char = theuser_name.charAt(i); if (!name_exp.test(the_char)) { error.val=2; return false; } } return true; }
Now I've checked Firebug and "city_opts" has the value of whatever is selected. So that part is working. But when I hit submit, the form isn't recognizing that a city was indeed selected. It still shows an error message regardless of a city being selected or not. Please help.Code:correct=checkSelOpts(sel_opt, error); if (!correct) { error_mes += errors[error.val] + '<br>'; } ...//else statement is further down...it's not the problem ... function checkSelOpts(city_opts, error){ if (city_opts="none") { error.val=4; return false; } return true; }


Reply With Quote

Bookmarks