Jump to content

JS help


darkfreaks

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.