I have a code here and now I want to add regular expressions to it.
On the “Bedrijfsnaam” it needs to be accepted to use alphabetic characters, numbers, spaces and a few symbols like: . – _ and @.
On the “Contactpersoon” it only needs to be accepted to use alphabetic characters, spaces and dots.
For the “Email” it needs to be accepted to use alphabetic characters and a ., followed by a @, then alphabetic characters and a -, a . and after that a maximum of 3 alphabetic characters //This is because i also want this email adresses to be able: r.kameel@noordkabels.nl or r.kameel@noord-kabels.nl
on “Telefoonnummer” it only needs to be accepted to use 10 digits.
This is the javascript code I allready have:
<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>
You will find a useful library for regular expressions at the following website:
http://regexlib.com/