Por que não funciona(JavaScript)

Oi pessoal.
Estou fazendo esta validação de senha:

[code]function checkPassword (nmSenha) {

if ((nmSenha.value.length < 6) || (nmSenha.value.length > 8)) {
   alert("A senha deve ter entre 6 e 8 caracteres");
}

else if (!((nmSenha.search(/(a-z)+/)) && (nmSenha.search(/(A-Z)+/)) && (nmSenha.value.search(/(0-9)+/)))) {
   alert("A senha deve conter pelo menos 1 letra maiúscula,1 minúscula e 1 número");
}  

} [/code]

No meu form chamo ela assim:

<TD><html:password property="nmSenha" maxlength="8" onchange="checkPassword(this);"  /></TD>

Só que só funciona a primeira parte,passa batido no else if.
O que pode estar errado?

[quote]nmSenha.search(/(a-z)+/))[/quote]Essa função exige uma string como parâmetro naum? Não teria q por aspas então?

Olá.
Onde ficariam as apspas?

Presta atencao no nmSenha.search do elseif - eh o que ta falhando, provavelmente.

Olá cv.
Qual poderia ser o erro?
Este método não é válido?
Não sei debugar isto…

Debugger javascript para firefox

https://addons.mozilla.org/firefox/1843/

WebDeveloper toolbar

https://addons.mozilla.org/firefox/60/

Example:

The page in Listing 34-4 lets you practice with the string.replace() and
string.search() methods and regular expressions in a friendly environment. The source text is a five-line excerpt from Hamlet. You can enter the regular expression to search for, and the replacement text as well. Note that the script completes the job of creating the regular expression object, so that you can focus on the other special characters used to define the matching string. All replacement activities act globally, because the g parameter is automatically appended to any expression you
enter.
Default values in the fields replace the contraction 'tis with “it is” after you click the “Execute replace( )” button. Notice that the backslash character in front of the apostrophe of 'tis (in the string assembled in mainString) makes the apostophe a non-word boundary, and thus allows the \B’t regular expression to find a match there. As described in the section on the string.search() method, the button connected to that method returns the offset character number of the matching string (or -1 if no match occurs).
You could modify the listing so that it actually replaces text in the HTML paragraph for IE4+ and NN6. The steps include wrapping the paragraph in its own element (for example, a SPAN), and invoking the replace() method on the innerHTML of that element. Assign the results to the innerHTML property of that element to complete the job.

HTML de exemplo:


<HTML>
<HEAD>
<TITLE>Regular Expression Replace and Search</TITLE>
<SCRIPT LANGUAGE="JavaScript">
var mainString = "To be, or not to be: that is the question:\n"
mainString += "Whether \'tis nobler in the mind to suffer\n"
mainString += "The slings and arrows of outrageous fortune,\n"
mainString += "Or to take arms against a sea of troubles,\n"
mainString += "And by opposing end them."

function doReplace(form) {
var replaceStr = form.replaceEntry.value
var delim = (form.caseSens.checked) ? "/g" : "/gi"
var regexp = eval("/" + form.regexp.value + delim)
form.result.value = mainString.replace(regexp, replaceStr)
}

function doSearch(form) {
var replaceStr = form.replaceEntry.value
var delim = (form.caseSens.checked) ? "/g" : "/gi"
var regexp = eval("/" + form.regexp.value + delim)
form.result.value = mainString.search(regexp)
}
</SCRIPT>
</HEAD>
<BODY>

<B>String Replace and Search with Regular Expressions</B>
<HR>
Text used for string.replace() and string.search() methods:<BR>
<B>To be, or not to be: that is the question:<BR>
Whether 'tis nobler in the mind to suffer<BR>
The slings and arrows of outrageous fortune,<BR>
Or to take arms against a sea of troubles,<BR>
And by opposing end them.</B>
<FORM>

Enter a regular expression to match:<INPUT TYPE="text" NAME="regexp" SIZE=25 VALUE="\B't">
<INPUT TYPE="checkbox" NAME="caseSens">Case-sensitive<BR>

Enter a string to replace the matching strings:<INPUT TYPE="text" NAME="replaceEntry" SIZE=30 VALUE="it "><P>
<INPUT TYPE="button" VALUE="Execute replace()" onClick="doReplace(this.form)">
<INPUT TYPE="reset">
<INPUT TYPE="button" VALUE="Execute search()" onClick="doSearch(this.form)"><P>

Result:<BR>
<TEXTAREA NAME="result" COLS=60 ROWS=5 WRAP="virtual"></TEXTAREA>
</FORM>
</BODY>
</HTML>

juliano ia ser melhor se voce postasse o link e nao copiasse a pagina de help em ingles ainda por cima no forum.

[quote=fmeyer]juliano ia ser melhor se voce postasse o link e nao copiasse a pagina de help em ingles ainda por cima no forum.

[/quote]

Isso não veio de uma página da net, isso eu tirei de um PDF do livro Bíblia do JavaScript.

E agora eu vou ser criticado por postar texto em inglês? Ele não tem obrigação de saber inglês (quando deveria, pelo menos pra leitura), mas o exemplo (HTML) está ali pra auxiliá-lo.

O que eu posso ter errado é não ter colocado um cabeçalho de introdução do meu post explicando de onde vem pra onde vai.

Olá Juliano
Obrigado pelo texto explicativo,foi muito útil.
Resolvi o problema.
Um abraço!!!
Fmeyer,valeu pela dica do Firefox!!!
…e não briguem gente,paz e amor!