Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2010
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Control problem based on two forms

    Control problem based on two forms

    Hello everyone,
    I have a problem with the control of my two forms
    principle it is good for the first form, but if I wanted to control my 2nd form, blocking ca
    Here's the script:

    Code:
    <html>
    <head>
    <script type="text/javascript" >
    function formValidation1(oEvent) {
    oEvent = oEvent || window.event;
    var txtField = oEvent.target || oEvent.srcElement;
    
    var txt_nom_pereck1=true;
    var msg=" ";
    if(document.getElementById("txt_nom_pere").value.length < 3 ){ txt_nom_pereck1=false; msg = msg + "Your name should be minimun 3 char length";}
    if(document.getElementById("txt_prenom_pere").value.length < 3 ){ txt_nom_pereck1=false; msg = msg + "Your name should be minimun 3 char length";}
    
    
    if(txt_nom_pereck1){document.getElementById("submit_etape4").style.display='block'; }
    else{document.getElementById("submit_etape4").style.display='none'; }
    }
    
    window.onload = function () {
    
    
    var submit_etape4 = document.getElementById("submit_etape4");
    
    var txt_nom_pere = document.getElementById("txt_nom_pere");
    var txt_prenom_pere = document.getElementById("txt_prenom_pere");
    
    var txt_courriel_pere = document.getElementById("txt_courriel_pere");
    var txt_courriel_pere_conf = document.getElementById("txt_courriel_pere_conf");
    
    
    
    var txt_nom_pereck1=false;
    document.getElementById("submit_etape4").style.display='none';
    txt_nom_pere.onkeyup = formValidation1;
    txt_prenom_pere.onkeyup = formValidation1;
    
    }
    
    //************Partie 2 : ******/////////////////////////////
    
    /*
    function formValidation2(oEvent) {
    oEvent = oEvent || window.event;
    var txtField = oEvent.target || oEvent.srcElement;
    
    var txt_nom_pereck2=true;
    var msg=" ";
    
    if(document.getElementById("txt_courriel_pere").value.length < 3 ){ txt_nom_pereck2=false; msg = msg + "Your name should be minimun 3 char length";}
    if(document.getElementById("txt_courriel_pere_conf").value.length < 3 ){ txt_nom_pereck2=false; msg = msg + "Your name should be minimun 3 char length";}
    
    
    if(txt_nom_pereck2){document.getElementById("submit_etape5").style.display='block'; }
    else{document.getElementById("submit_etape5").style.display='none'; }
    }
    
    window.onload = function () {
    
    
    var submit_etape5 = document.getElementById("submit_etape5");
    
    var txt_courriel_pere = document.getElementById("txt_courriel_pere");
    var txt_courriel_pere_conf = document.getElementById("txt_courriel_pere_conf");
    
    
    
    var txt_nom_pereck2=false;
    document.getElementById("submit_etape5").style.display='none';
    txt_nom_pere.onkeyup = formValidation2;
    txt_prenom_pere.onkeyup = formValidation2;
    }
    
    Je voulais activer cette partie pour comtrole le Form 2
    Le probleme existe au niveau des nom des fonctions
    
    I wanted this part to enable the Comtrol Form 2
    The problem exists at the level of function names
    */
    </script>
    
    </head>
    <body >
    <form method=" post" action="form-success.php">
    <table>
    <tr>
    <td>First Name</td>
    <td><input type="text" id="txt_nom_pere" name="FirstName"></td>
    </tr>
    <tr>
    <td>First Name</td>
    <td><input type="text" id="txt_prenom_pere" name="FirstName"></td>
    </tr>
    </table>
    <input type="button" id="submit_etape4" value="Sign Up!!" style="display:none;"  /> 
    </form>
    
    
    
    
    <form method=" post" action="form-success.php">
    <table>
    <tr>
    <td>First Name</td>
    <td><input type="text" id="txt_courriel_pere" name="FirstName"></td>
    </tr>
    <tr>
    <td>First Name</td>
    <td><input type="text" id="txt_courriel_pere_conf" name="FirstName"></td>
    </tr>
    </table>
    <input type="button" id="submit_etape5" value="Sign Up!!" style="display:none;"  /> 
    </form>
    
    
    </body>
    </html>

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I think this is more about Javascripting than PHP ...

    Your <form>s need to have unique names and id's so it knows which one to hide or show.



    <form name="form1" id="form1" method="post" action="form-success.php">
    .
    .
    .
    </form>


    <form name="form2" id="form2" method="post" action="form-success.php">
    .
    .
    .
    </form>



    .


  •  

    Posting Permissions

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