Min kod:Korrekt Email adress
<code>
<script type="text/javascript">
/* Detta script finns att hämta på http://www.jojoxx.net och
får användas fritt så länge som dessa rader står kvar. */
String.prototype.isValidEmail = function(){
return !!this.match(/^([a-zA-Z0-9]{1}([a-zA-Z0-9\.\-\_]*)[a-zA-Z0-9]{1})@([a-zA-Z0-9]{1}([a-zA-Z0-9\.\-\_]*)[a-zA-Z0-9]{1})\.([a-zA-Z]{2,4})$/)
}
function tecken() {
if (document.kontroll.username.value=="") {
alert("You have to enter your username, Begin with a letter, and use only letters (a-z), numbers (0-9), the underscore (_), and no spaces.");
return false;
} else if (document.kontroll.email.value=="") {
alert("You have to enter your email, You must activate your account after signing up, this is for your own safety (Ex: my@mail.com).");
return false;
} else if (!document.kontroll.email.value.isValidEmail()) {
alert("You have to enter a valid email, (Ex: my@mail.com), read our rules.");
return false;
} else if (document.kontroll.remail.value=="") {
alert("You have to verify your email.");
return false;
} else if (document.kontroll.password.value=="") {
alert("You have to enter your password!");
return false;
} else if (document.kontroll.rpassword.value=="") {
alert("You have to verify your password!");
return false;
} else {
alert("Thank you, You will now be sent to next site.");
return true;
}
}
</script>
</code>
Den fungerar bra, men har ett fel.
Den godkänner inte min_@email.com men den kan godkänna min_e@email.com
Tacksam om ni kunde redigera min kod så den klarar av _ eller - på slutet.
Mvh HassanSv: Korrekt Email adress
return !!this.match(/^([a-zA-Z0-9]{1}([a-zA-Z0-9\.\-\_]*)[a-zA-Z0-9\_\-]{1})@([a-zA-Z0-9]{1}([a-zA-Z0-9\.\-\_]*)[a-zA-Z0-9]{1})\.([a-zA-Z]{2,4})$/)