Visualizzazione dei risultati da 1 a 3 su 3

Discussione: validazione form

  1. #1

    validazione form

    non mi va... aiutino?

    codice:
    function validateForm() {
    var name = document.forms[0].name;
    var email = document.forms[0].email;
    var confirmemail = document.forms[0].confirmmail;
    var errorstring = "";
    	if (name = "") {
    		errorstring = errorstring + "- Your name is required";
    	}
    	if (email = confirmemail) {
    		//good
    	} else {
    		errorstring = errorstring + "- Your email address does not match";
    	}
    if (errorstring = "") {
    		document.forms[0].submit();
    	} else {
    		alert ("Error: " + errorstring);
    	}
    }

  2. #2
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    21
    x fare ugalianza si usa == nn = e document.forms[0].name.value
    ecco quello giusto
    codice:
    function validateForm() {
    var name = document.forms[0].name.value;
    var email = document.forms[0].email.value;
    var confirmemail = document.forms[0].confirmmail.value;
    var errorstring = "";
    	if (name == "") {
    		errorstring +="- Your name is required";
    	}
    	if (email == confirmemail && email !="") {
    		//good
    	} else {
    		errorstring += "- Your email address does not match";
    	}
    if (errorstring == "") {
    		document.forms[0].submit();
    	} else {
    		alert ("Error: " + errorstring);
    	}
    }

  3. #3
    sono il classico newbie! grazie!

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 © 2025 vBulletin Solutions, Inc. All rights reserved.