Visualizzazione dei risultati da 1 a 6 su 6

Discussione: controllo passw

  1. #1

    controllo passw

    Ciao a tutti, sto facendo la pagina del cambio password, ho creato tre cambi: password corrente, password nuovo, password conferma.
    Ho fatto controllo così

    -------------------------------
    function test(theForm) {
    var vecc = document.cambio.vecchio.value
    var passw = document.cambio.passwold.value
    var nuov = document.cambio.nuovo.value
    var conf = document.cambio.conferma.value

    if ((vecc == "") || (nuov == "") || (conf == "")){
    alert("Compilare tutti i campi:\n - PASSWORD CORRENTE;\n - NUOVA PASSWORD;\n - CONFERMA PASSWORD.");
    if (vec == ""){ setTimeout("vecchio.focus();",300);}
    else if (nuov == ""){ setTimeout("nuovo.focus();",300);}
    else if (conf == ""){setTimeout("conferma.focus();",300);}
    }
    else if (vecc == nuov) {
    alert("I campi NUOVA PASSWORD e PASSWORD CORRENTE sono uguali.\n Digitare una password diversa se si vuole procedere con la modifica.");
    document.cambio.nuovo.value = "";
    document.cambio.conferma.value = "";
    document.cambio.nuovo.focus();
    return false;
    }
    else if (nuov != conf) {
    alert("I campi NUOVA PASSWORD e CONFERMA PASSWORD sono discordanti. \n Digitarli nuovamente.");
    document.cambio.nuovo.value = "";
    document.cambio.conferma.value = "";
    document.cambio.nuovo.focus();
    return false;
    }
    else if (vecc != passw) {
    alert("Il password corrente non è correto. \n Digitarli nuovamente.");
    document.cambio.vecc.value = "";
    document.cambio.vecc.focus();
    return false;
    }
    return true;
    if(confirm('Sicuro di assegnare?'))document.cambio.submit();
    }
    ------------------------------------------------------------------

    e il form:
    ---------------------------------------------------------------
    <form action="<%=MM_editAction%>" method="POST" name="cambio" id="cambio" onsubmit="return test(this)">
    ------------------------------------------------------------------

    quando ho fatto diversi password nei campi nuovo e conferma, si accorge che sono diversi, e appare l'alert, quando ho cliccato ok e procede UGUALMENTE, come mai??
    Poi ho fatto hidden del input password corrente "passwold" per distinguere al campo "vecchio" per sicurezza, se è uguale o diverso, appare lo stesso alert "sono diversi password correnti" e cliccato "ok" e procede uguale, come faccio??
    Grazie
    Gabry
    ..:: GSFLASH ::..
    HTTP://WWW.GSFLASH.IT
    MCTS - ACP - OCP - ECDL
    Ubuntu 7.10/OpenSuse 10.3/Vista Premium/MacOSX Leopard
    My authentic japanese name is 薗田Sonoda (garden field) 大河 Taiga (big river)

  2. #2
    nessuno mi risponde?
    ..:: GSFLASH ::..
    HTTP://WWW.GSFLASH.IT
    MCTS - ACP - OCP - ECDL
    Ubuntu 7.10/OpenSuse 10.3/Vista Premium/MacOSX Leopard
    My authentic japanese name is 薗田Sonoda (garden field) 大河 Taiga (big river)

  3. #3
    Utente di HTML.it L'avatar di killer
    Registrato dal
    Jan 2002
    Messaggi
    279
    Il codice Js è questo:
    codice:
    function test(theForm) 
    { 
    	var vecc = document.cambio.vecchio.value;
    	var passw = document.cambio.passwold.value; 
    	var nuov = document.cambio.nuovo.value; 
    	var conf = document.cambio.conferma.value; 
    
    	if ((vecc == "") || (nuov == "") || (conf == ""))
    	{ 
    		alert("Compilare tutti i campi:\n - PASSWORD CORRENTE;\n - NUOVA PASSWORD;\n - CONFERMA PASSWORD."); 
    		if (vec == "")
    		{ 
    			setTimeout("vecchio.focus();",300);
    		} 
    		else if (nuov == "")
    		{ 
    			setTimeout("nuovo.focus();",300);
    		} 
    		else if (conf == "")
    		{
    			setTimeout("conferma.focus();",300);
    		} 
    		return false;
    	} 
    	else if (vecc == nuov) 
    	{ 
    		alert("I campi NUOVA PASSWORD e PASSWORD CORRENTE sono uguali.\n Digitare una password diversa se si vuole procedere con la modifica."); 
    		document.cambio.nuovo.value = ""; 
    		document.cambio.conferma.value = ""; 
    		document.cambio.nuovo.focus(); 
    		return false; 
    	} 
    	else if (nuov != conf) 
    	{ 
    		alert("I campi NUOVA PASSWORD e CONFERMA PASSWORD sono discordanti. \n Digitarli nuovamente."); 
    		document.cambio.nuovo.value = ""; 
    		document.cambio.conferma.value = ""; 
    		document.cambio.nuovo.focus(); 
    		return false; 
    	} 
    	else if (vecc != passw) 
    	{ 
    		alert("Il password corrente non è correto. \n Digitarli nuovamente."); 
    		document.cambio.vecc.value = ""; 
    		document.cambio.vecc.focus(); 
    		return false; 
    	} 
    
    	if(confirm('Sicuro di assegnare?'))
    	{
    		return true;
    	}
    	
    	return false;
    }
    Nel form devi fare il submit utilizzando un normale INPUT di tipo SUBMIT e lasciando il resto inalterato.

    _| killer |_

  4. #4
    Ti ringrazio lo stesso e ho fatto altro tipo e vediamo se per te va bene:

    code:
    --------------------------------------------------------------------
    function controllo(theForm)
    {

    if (theForm.vecchio.value == "")
    {
    alert("Inserire un valore per il campo \"vecchio password\".");
    theForm.vecchio.focus();
    return (false);
    }

    if (theForm.vecchio.value.length > 15)
    {
    alert("Inserire al massimo 15 caratteri nel campo \"vecchio password\".");
    theForm.vecchio.focus();
    return (false);
    }
    if (theForm.nuovo.value == "")
    {
    alert("Inserire un valore per il campo \"nuovo password\".");
    theForm.nuovo.focus();
    return (false);
    }

    if (theForm.nuovo.value.length < 3)
    {
    alert("Inserire almeno 3 caratteri nel campo \"nuovo password\".");
    theForm.nuovo.focus();
    return (false);
    }

    if (theForm.nuovo.value.length > 15)
    {
    alert("Inserire al massimo 15 caratteri nel campo \"nuovo password\".");
    theForm.nuovo.focus();
    return (false);
    }

    if (theForm.conferma.value != theForm.nuovo.value)
    {
    alert("Password di conferma errata, ridigitare prego.");
    theForm.conferma.value = ("");
    theForm.conferma.focus();
    return (false);
    }

    if (theForm.nuovo.value == theForm.vecchio.value)
    {
    alert("Nuovo password è uguale a quello vecchio, a che serve cambi?? ridigitare prego.");
    theForm.nuovo.value = ("");
    theForm.conferma.value = ("");
    theForm.conferma.focus();
    return (false);
    }

    if (theForm.vecchio.value != theForm.passwold.value)
    {
    alert("Password corrente non è corretto, ridigitare prego.");
    theForm.vecchio.value = ("");
    theForm.vecchio.focus();
    return (false);
    }
    return confirm('Sicuro di cambiare?');
    }
    ------------------------------------------------------------------

    e il form:
    -----------------------------------------
    <form action="<%=MM_editAction%>" method="POST" name="cambio" id="cambio" onsubmit="return controllo(this)">
    --------------------------------------------

    Funziona perfettamente, ma va bene lo stesso questo? O sarebbe meglio quello che mi hai dato?
    Grazie
    ..:: GSFLASH ::..
    HTTP://WWW.GSFLASH.IT
    MCTS - ACP - OCP - ECDL
    Ubuntu 7.10/OpenSuse 10.3/Vista Premium/MacOSX Leopard
    My authentic japanese name is 薗田Sonoda (garden field) 大河 Taiga (big river)

  5. #5
    Utente di HTML.it L'avatar di killer
    Registrato dal
    Jan 2002
    Messaggi
    279
    non mi va di leggerlo tutto...
    se hai testato il tuo e funziona allora usalo..

    _| killer |_

  6. #6
    infatti eh eh grazie lo stesso comunque
    Buona serata da Gabriele.
    ..:: GSFLASH ::..
    HTTP://WWW.GSFLASH.IT
    MCTS - ACP - OCP - ECDL
    Ubuntu 7.10/OpenSuse 10.3/Vista Premium/MacOSX Leopard
    My authentic japanese name is 薗田Sonoda (garden field) 大河 Taiga (big river)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.