Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

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,811
    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