codice:
<html>
<head>
<script type="text/javascript" language="JavaScript">
<!--
function checkData( __hForm )
{
if ( __hForm.elements["cliente"].value == "" ) {
alert( "Cliente non valido." );
return false;
}
if ( !(/^\d+(|\.\d+)$/).test(__hForm.elements["importo"].value) ) {
alert( "Importo non valido." );
return false;
}
return true;
}
//-->
</script>
</head>
<body>
<form onsubmit="return checkData( this );">
Cliente:
<input type="text" name="cliente" />
Importo:
<input type="text" name="importo" />
<input type="submit" />
</form>
</body>
</html>
onsubmit va nel <form>