codice:
<script language="Javascript" type="text/javascript">
function ValidateThenPost() {
var testMail = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i;
var FN = document.getElementById('email');
var CA = document.getElementById('commentarea');
var CP = document.getElementById('nome');
if (CP != undefined)
{
if (CP.value == '') { CP.style.backgroundColor = '#ffcccc'; return; } else { CP.style.backgroundColor = '#ffffff'; }
}
if (FN != undefined)
if (FN.value == '' || !testMail.test(FN.value)) { FN.style.backgroundColor = '#ffcccc'; return; } else { FN.style.backgroundColor = '#ffffff'; }
if (CA.value == '') { CA.style.backgroundColor = '#ffcccc'; return; } else { CA.style.backgroundColor = '#ffffff'; }
document.getElementById('commentform').submit();
}
</script>