Ok this is easy i am sure but I am stuck. Basically its this simple form…
<form action="send_it.asp" method="post" name="emailform" >
<input type="text" name="email_address_sender" size="40" >
</form>
<a href="#" onclick="return checkForm(document.emailform)" class="button" id="buttonOK">
which submits to this simple email validation function, which works if the email is incorrect, but of ots correct it wont submit to my “send_it.asp” page any ideas guys???
<script>
function isEmpty( str){
strRE = new RegExp( );
strRE.compile( '^[\s ]*$', 'gi' );
return strRE.test( str.value );
}
function notValidEmail( str ){
mailRE = new RegExp( );
mailRE.compile( '^[\._a-z0-9-]+@[\.a-z0-9-]+[\.]{1}[a-z]{2,4}$', 'gi' );
return !(mailRE.test( str.value ));
}
function notChecked( box ){
if( box.checked ){
return false;
}
else{
return true;
}
}
//it accepts "form" as parameter
function checkForm( form ){
//lets check if Name text field is empty. This field has name "name".
if( isEmpty( form.name ) ){
alert( 'Name is required field!' );
return false;
}
//now let's check if email is correct. This field name is "email"
if( notValidEmail( form.email_address_sender ) ){
alert( 'Please enter a valid email address' );
return false;
}
//now let's check if checkbox is checked. This field name is "subscribe"
if( notChecked( form.subscribe ) ){
alert( 'Subscribe box is required field!' );
return false;
}
alert('Form is okay!!!');
return false;
}
</script>