prueba con esto:
Código HTML:
Ver original
<script type="text/javascript">
window.onload = function() {
var mail = document.getElementById("mail2");
mail.onpaste = function(e){
e.preventDefault();
alert('no paste plx!!');
};
};
function validarMail(id) {
var patron = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (patron.test(document.getElementById(id).value)){
return true;
}
return false;
}
function valida(id1, id2){
var mail1 = document.getElementById(id1);
var mail2 = document.getElementById(id2);
if(validarMail(id1) && validarMail(id2) && mail1.value == mail2.value){
return true;
}
return false;
}
<form method="post" action="" onsubmit="if(!valida('mail1', 'mail2')){ alert('error mails!!'); return false; }"> <input type="text" value="" name="mail1" id="mail1" /><br/> <input type="text" value="" name="mail2" id="mail2" /><br/> <input type="submit" value="go!">
<?php
echo $_POST["mail1"] ." - ".$_POST["mail2"];
?>