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 6 of 6

Thread: Validation

  1. #1
    Regular Coder
    Join Date
    Aug 2012
    Posts
    121
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Validation

    I use an external validation .js of a source for my contact form.
    Code:
    <script type="text/javascript" src="jquery.validate.js"></script>
    <script type="text/javascript">
            $(document).ready(function(){
                $('#order-form').validate();
            });
    </script>
    I have an onsubmit function that should be done after validation. How can I set validation run first?

    Pls help to explain $(document).ready(function() and $('#order-form').validate()

    I want to do
    1. validation
    2. function 1
    3. submit (action = file.php )
    4. function 2 after submit

    Where can I put function 1 and function 2?

    I use function 2 to clear all data after submit succeed
    Last edited by docco; 07-23-2013 at 10:09 AM.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,477
    Thanks
    6
    Thanked 980 Times in 953 Posts
    Read the documentation (assuming you have this plugin), the submitHandler option might be of particular interest.

  • #3
    Regular Coder
    Join Date
    Aug 2012
    Posts
    121
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by VIPStephan View Post
    Read the documentation (assuming you have this plugin), the submitHandler option might be of particular interest.
    Thanks, in case I use this plug-in, how I will declare?

    In my body
    Code:
    <script type="text/javascript">
            $(document).ready(function(){
                $('#contact-form').validate();
            });
    </script>
    Now I want after submit, the div of contact to be hidden by javascript
    Code:
    document.getElementById('contactDiv').style.display = 'none';
    Therefore I do
    Code:
    <script type="text/javascript">
    $(document).ready(function(){
    		$('#contact-form').validate({
    		  submitHandler: function(form) {
    		    $("#submitWindow").hide();
    		    form.submit();
    		  }
    		});
    });
    </script>
    Bt it doesnt work, please help where to insert this code???
    Last edited by docco; 07-23-2013 at 06:22 PM.

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,477
    Thanks
    6
    Thanked 980 Times in 953 Posts
    Your syntax looks correct but you have to be more elaborate for us to be able to help you. At the very best provide a link to your page, if that’s not possible then your complete HTML and JS might also be doing the trick but at the very very least you should tell us if there are any errors in the browser’s JS console and if yes which ones.

  • #5
    Regular Coder
    Join Date
    Aug 2012
    Posts
    121
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by VIPStephan View Post
    Your syntax looks correct but you have to be more elaborate for us to be able to help you. At the very best provide a link to your page, if that’s not possible then your complete HTML and JS might also be doing the trick but at the very very least you should tell us if there are any errors in the browser’s JS console and if yes which ones.
    Thanks you, it works now, only typing error.
    BTW, can you help me function for reset button (of form) in case using this validation plug-in.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,961
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Code:
    <button type="reset">Reset</button> OR
    <input type="reset" value="Reset" />


  •  

    Posting Permissions

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