Results 1 to 7 of 7

Thread: 2 function with submit event handler

  1. #1
    Join Date
    Feb 2010
    Posts
    63
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default 2 function with submit event handler

    I want 2 functions checked onsubmit event handler.

    First function checkchars(cur) has to be true : max 5 chars for textwidth 5 cm, max 10 chars for textwidth 10 cm, .... .

    Second function radio_button_checker() has to be true : check if a radio button is hit.

    I tried a lot of things in vain.

    Prototype



    Yam.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    onSubmit="if (!checkchars(this)||!radio_button_checker()) { return false; }"

    As I said in the other thread, always remember the final semi-colons. It may not seem important now, but it will really help to debug things later.

    Also, this assumes that your functions are working now.

    Alternatively you could place that in a new function like this:
    Code:
    function checkform(form) {
    if (checkchars(form)&&radio_button_checker()) { return true; }
    return false;
    }
    Use it like this:
    onSubmit="return checkchars(this);"
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Feb 2010
    Posts
    63
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    onSubmit="if (!checkchars(this)||!radio_button_checker()) { return false; }"
    The alert works, but when the number of chars is ok ... nothing happens.

    The new function : alert for chars works, but no alert when no radio button is checked.

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That is because of the way that it processes the AND/OR commands.
    It fails before continuing.

    Try this:
    Code:
    function checkform(form) {
    var check1 = checkchars(form);
    var check2 = radio_button_checker();
    if (check1==true&&check2==true) { return true; }
    return false;
    }
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Feb 2010
    Posts
    63
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Almost ... but the submit doesn't send anything. When the text is send, it appears under the textfield.

    onSubmit="return checkform(this);"

    Test

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Try this:
    onSubmit="if (!checkform(this)) { return false; };"
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Feb 2010
    Posts
    63
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    same result

Bookmarks

Posting Permissions

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