darkfreaks Posted November 8, 2009 Share Posted November 8, 2009 how would i remove the forn name value from the following function and make it so spaces and every character/symbol is not allowed except dashes and under scores? function validatePwd() { var invalid = " "; // Invalid character is a space var minLength = 4; // Minimum length var maxLength = 50;//Maximum length var pw1 = document.myForm.password.value; // check for minimum length if (document.myForm.password.value.length < minLength) { alert('Your password must be at least ' + minLength + ' characters long. Try again.'); return false; //check for maximum length if (document.myForm.password.value.length > maxLength) { alert('Your password must not exceed ' + minLength + ' characters long. Try again.'); return false; } // check for spaces if (document.myForm.password.value.indexOf(invalid) > -1) { alert("Sorry, spaces are not allowed."); return false; } else { alert('Nice job.'); return true; } } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.