Hello, I'm creating a form which gives errors etc.
But I also need regular expressions on it and I can't get it done anymore by myself, so I really hope someone can help me.
This is the code:
Code:<script language="JavaScript" type="text/javascript"> function validateForm() { var x=document.forms["myForm"]["Bedrijfsnaam"].value; if (x==null || x=="") { alert("De bedrijfsnaam is niet ingevuld, u wordt verzocht dit veld in te vullen."); return false; } var x=document.forms["myForm"]["Contactpersoon"].value; if (x==null || x=="") { alert("De naam van de contactpersoon is niet ingevuld, u wordt verzocht dit veld in te vullen."); return false; } var x=document.forms["myForm"]["Email"].value; if (x==null || x=="") { alert("Het E-mailadres van de contactpersoon is niet ingevuld, u wordt verzocht dit veld in te vullen."); return false; } var x=document.forms["myForm"]["Telefoonnummer"].value; if (x==null || x=="") { alert("Het telefoonnummer van de contactpersoon is niet ingevuld, u wordt verzocht dit veld in te vullen."); return false; } var x=document.forms["myForm"]["option1"].value; if (x==null || x=="") { alert("Zoekwoordcombinatie 1 van de gewenste zoekwoordcombinaties waarop uw bedrijf online vindbaar wil zijn is niet ingevuld, u wordt verzocht dit veld in te vullen."); return false; } } </script>
HTML Code:<div id="content" role="main"> <h6>Velden met een * zijn verplicht.</h6> <br /> <div id="form"> <form name="myForm" action="http://localhost/MKB_zoeker_2012/wordpress/340-2/"" onsubmit="return validateForm()" method="post"> <p>Bedrijfsnaam*:</p> <div id="input"><input type="text" name="Bedrijfsnaam" size="40" /></div> <p>Contactpersoon*:</p> <div id="input"><input type="text" name="Contactpersoon" size="40" /></div> <p>E-mailadres*:</p> <!--Check of bestaat zou handig zijn--> <div id="input"><input type="text" name="Email" size="40" /></div> <p>Telefoonnummer*:</p> <div id="input"><input type="text" name="Telefoonnummer" size="40" maxlength="10" /></div> <p>Gewenste zoekwoordcombinaties waarop uw bedrijf online vindbaar wil zijn (max. 3):</p> <p>Zoekwoordcombinatie 1*:</p> <div id="input"><input type="text" name="option1" size="40" /></div> <p>Zoekwoordcombinatie 2:</p> <div id="input"><input type="text" name="option2" size="40" /></div> <p>Zoekwoordcombinatie 3:</p> <div id="input"><input type="text" name="option3" size="40" /></div> </div> <div id="submitbutton"><input type="submit" value="Aanmelding indienen" /> </div> </form>


Reply With Quote

Bookmarks