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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    104
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Issue with form validation and loading

    Hi All,

    I need some help here

    I have a form that is using the JavaScript Form Validation found here
    JavaScript Form Validation : quick and easy!

    It works great on my site. This a sample of my validation added to the html page

    Code:
    <script  type="text/javascript">
     var frmvalidator = new Validator("sform");
     frmvalidator.addValidation("fname","req","Please Enter Your First Name");
     frmvalidator.addValidation("lname","req","Please Enter Your Last Name");
    </script>
    This is the code for the spinner to work

    Code:
    <script type="text/javascript">        
     $(function() {
     	
     	
     $('#sform').on("submit", function () {
    
        setTimeout(function () {
    
              $('#loading').show();
    
        }, 100);
    
      });
      });
      
    };
    
     </script>
    The problem is I don't know how to write the code to say if there is not any validation errors load the SetTimeout function (Activate the spinner).

    Any help would be appreciated.

    Thanks, Dan

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,191
    Thanks
    80
    Thanked 4,562 Times in 4,526 Posts
    You'd have to get and change the code in that validator.

    Currently, it apparently is triggering via the onsubmit of the <form> and returning false on any errors.

    You would need to instead invoke the validator via a direct call to the master validation function and invoke your "loading" only on a return of true (and then do the form submit() call).

    That code is pretty ancient. Witness that it depends on the NAME of the <form>, which is long obsolete. It should be using the ID of the <form>.

    There are other more modern validators out there. Look around.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Since you're using jQuery, try this one: jQuery Validation Plugin | Form validation with jQuery
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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