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; } } } Link to comment https://forums.phpfreaks.com/topic/180799-js-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.