Regular expressions in javascript

member

New Member
Hi I'm new to javascript and I have the following function:\[code\]function checkform() {var theForm = document.getElementById('login_form');var regName = /^[a-zA-Z ]+$/;var firstname = theForm.firstname.value; if ((firstname == "" || theForm.firstname.value.length > 30 ) && (regName.test(firstName) == false)) { alert("That is not a valid first name!"); theForm.firstname.focus(); return false; }}\[/code\]It works in the sense that it checks that the data is not empty and not greater than 30. My problem is that is currently allows the user to enter data that does not match my regex i.e. numerical data. I can not see any problems with the logic.Thanks
 
Back
Top