Results 1 to 5 of 5

Thread: Submit damn you, submit!

  1. #1
    82
    posts
    Registered User

    Submit damn you, submit!

    Ok this is easy i am sure but I am stuck. Basically its this simple form...
    Code:
       <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????

    Code:
    <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>

  2. #2
    82
    posts
    Registered User
    anyone?

  3. #3
    183
    posts
    Registered User
    Try adding form.submit() to the end of your checkForm function

  4. #4
    82
    posts
    Registered User
    Hi,

    I tried that but no joy. Technically I can't understand why this doesnt work, I can get it to alert an error if the email is incorrect but if its correct the status bar just says 'error on page', and nothing happens. What even more frustrating is that I have actually got it to work on my work pc, but here at home it doesnt.

    Any more ideas

  5. #5
    icio's Avatar
    3,810
    posts
    looks better in lowercase
    Shouldn't that be a `return true` at the end of your `checkForm` function?
    "60% of the time it works... every time." -- Paul Rudd as Brian Fantana.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012