SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict Feudalism's Avatar
    Join Date
    Jun 2002
    Location
    Buenos Aires, Argentina
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    2 onsubmit, or 2 functions in one

    As I cant put two "onsubmit" function calls in one form,

    I need to join these two scripts into one.

    In One side, I have....

    Code:
    var testresults
    function checkemail(){
    var str=document.validation.emailcheck.value
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(str))
    testresults=true
    else{
    alert("Please input a valid email address!")
    testresults=false
    }
    return (testresults)
    }
    and... on the another side..

    Code:
    <script>
    function submitonce(theform){
    //if IE 4+ or NS 6+
    if (document.all||document.getElementById){
    //screen thru every element in the form, and hunt down "submit" and "reset"
    for (i=0;i<theform.length;i++){
    var tempobj=theform.elements[i]
    if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
    //disable em
    tempobj.disabled=true
    }
    }
    }
    </script>

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ehhhhmmmm ..... wrong forum there buddy " did you happen to notice to thing at the top that says THIS IS NOT THE JAVASCRIPT FORUM"

  3. #3
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DC erm.. if thats the case mate, why have I received a javascipt update email from sitepoint with this thread in and why at the top is this present? "

    + SitePoint Forums > Program Your Site > JavaScript
    - 2 onsubmit, or 2 functions in one

    Apologies if the thread has been moved! lol

    Gav

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As I cant put two "onsubmit" function calls in one form,
    Why not?

    onsubmit="function1();function2()";

    or

    Code:
    <form onsubmit="two_in_one()" >
    
    function two_in_one()
    {
         function1();
         function2();
    }

  5. #5
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gRoberts
    DC erm.. if thats the case mate, why have I received a javascipt update email from sitepoint with this thread in and why at the top is this present? "

    + SitePoint Forums > Program Your Site > JavaScript
    - 2 onsubmit, or 2 functions in one

    Apologies if the thread has been moved! lol

    Gav
    It has been moved from the java section to the javascript section


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
  •