SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onblur problem,please help

    Code:
    <html>
    
    <head>
    
    
    
    
    <script language=Javascript type="text/javascript">
    
    function checkname(x)
    {
    
    if(x==""){
    window.alert("you must enter a username")
    
    
    reg.username.select()
    reg.username.focus()
    
    
    }
    
    }
    
    
    function checkpass(y)
    {
    
    if(y==""){
    window.alert("you must enter a password")
    reg.password.select()
    reg.password.focus()
    
    }
    
    
    }
    </script>
    
    </head>
    <body>
    
    
    <form  name=reg method="POST" action="login.php">
    	<p>&nbsp;</p>
    	<p><b><font size="5">
    	 You must login first before you order any book</font></b></p>
    	<p>
    	Username
    	<input type="text" name="username" size="20" 
    		onblur="checkname(document.reg.username.value);"></p>
    	
    	<p>Password
    	<input type="text" name="password" size="20" 
    		onblur="checkpass(document.reg.password.value);"></p>
    	
    </form>
    
    </body>
    
    </html>

    there is a bugs(script error) in this script,can anyone able to modify it to a bugs free code?
    The warning will pop up non-stop!
    U may try to run it for better understand my problem.Thanks.

  2. #2
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps this script of mine can help you.

    <html>
    <head>
    <title>Formulareingaben &uuml;berpr&uuml;fen</title>

    <script type="text/javascript">
    function testit()
    { document.formularEins.texta.value="";
    document.formularEins.vorname.style.border="";
    document.formularEins.name.style.border="";
    document.formularEins.strasse.style.border="";
    document.formularEins.nummer.style.border="";
    document.formularEins.plz.style.border="";
    document.formularEins.ort.style.border="";
    document.formularEins.mail.style.border="";
    document.formularEins.username.style.border="";
    document.formularEins.passwort1.style.border="";
    document.formularEins.passwort2.style.border="";

    if(document.formularEins.vorname.value=="")
    { document.formularEins.texta.value="Bitte Vorname eingeben";
    document.formularEins.vorname.style.border="3px solid #8000DA";
    return false;
    }
    if(document.formularEins.name.value=="")
    { document.formularEins.texta.value="Bitte Name eingeben";
    document.formularEins.name.style.border="3px solid #8000DA";
    return false;
    }
    if(document.formularEins.strasse.value=="")
    { document.formularEins.texta.value="Bitte Strasse eingeben";
    document.formularEins.strasse.style.border="3px solid #8000DA";
    return false;
    }


    var HnrIstZahl = true;
    for (i = 0; i < document.formularEins.nummer.value.length; ++i)
    { if (document.formularEins.nummer.value.charAt(i) < "0" || document.formularEins.nummer.value.charAt(i) > "9")
    { HnrIstZahl = false;
    }
    }
    if(HnrIstZahl == false || document.formularEins.nummer.value == "")
    { document.formularEins.texta.value="Bitte Hausnummer eingeben";
    document.formularEins.nummer.style.border="3px solid #8000DA";
    return false;
    }


    var PlzIstZahl = true;
    for (i = 0; i < document.formularEins.plz.value.length; ++i)
    { if (document.formularEins.plz.value.charAt(i) < "0" || document.formularEins.plz.value.charAt(i) > "9")
    { PlzIstZahl = false;
    }
    }
    if(PlzIstZahl == false || document.formularEins.plz.value.length != "5")
    { document.formularEins.texta.value="Bitte 5-stellige Postleitzahl eingeben";
    document.formularEins.plz.style.border="3px solid #8000DA";
    return false;
    }


    if(document.formularEins.ort.value=="")
    { document.formularEins.texta.value="Bitte Ort eingeben";
    document.formularEins.ort.style.border="3px solid #8000DA";
    return false;
    }
    if(document.formularEins.mail.value.indexOf("@") == "-1")
    { document.formularEins.texta.value="Bitte E-Mail Adresse eingeben";
    document.formularEins.mail.style.border="3px solid #8000DA";
    return false;
    }
    if(document.formularEins.username.value.length<6)
    { document.formularEins.texta.value="Bitte Username mit mind. 6 Zeichen eingeben";
    document.formularEins.username.style.border="3px solid #8000DA";
    return false;
    }
    if(document.formularEins.passwort1.value!=document.formularEins.passwort2.value || document.formularEins.passwort1.value=="")
    { document.formularEins.texta.value="Bitte Passwort eingeben";
    document.formularEins.passwort1.style.border="3px solid #8000DA";
    document.formularEins.passwort2.style.border="3px solid #8000DA";
    return false;
    }
    else
    { document.formularEins.texta.value="ok";
    return true;
    }

    }
    </script>
    </head>
    <body>

    <form name="formularEins" onSubmit="return testit()" method="post" action="mailto:Isa20bella@web.de">
    <table>
    <tr>
    <td>Vorname/td>
    <td><input type="text" name="vorname" value="" length="10" bgcolor="#FF0000"></td>
    <td>Name/td>
    <td><input type="text" name="name" value="" length="10"></td>
    </tr>
    <tr>
    <td>Strasse/td>
    <td><input type="text" name="strasse" value="" length="10"></td>
    <td>Nummer/td>
    <td><input type="text" name="nummer" value="" length="10"></td>
    </tr>
    <tr>
    <td>PLZ/td>
    <td><input type="text" name="plz" value="" length="10"></td>
    <td>Ort/td>
    <td><input type="text" name="ort" value="" length="10"></td>
    </tr>
    <tr>
    <td>E-Mail/td>
    <td><input type="text" name="mail" value="" length="10"></td>
    </tr>
    <tr>
    <td>Username/td>
    <td><input type="text" name="username" value="" length="10"></td>
    </tr>
    <tr>
    <td>Passwort/td>
    <td><input type="password" name="passwort1" value="" length="10"></td>
    </tr>
    <tr>
    <td>Passwort again/td>
    <td><input type="password" name="passwort2" value="" length="10"></td>
    </tr>
    <tr>
    <td><br><input type="submit" name="abschicken" value="Abschicken"></td>
    <td><br><input type="reset" name="loeschen" value="Loeschen"></td>
    </tr>
    </table>

    <br><textarea name="texta" rows="2" cols="30"></textarea>
    </form>

    </body>
    </html>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •