Hello and welcome to our community! Is this your first visit?
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
    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

    <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");
    This is the code for the spinner to work

    <script type="text/javascript">        
     $(function() {
     $('#sform').on("submit", function () {
        setTimeout(function () {
        }, 100);
    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. #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 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.
    Be yourself. No one else is as qualified.

  3. #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Thanked 256 Times in 252 Posts
    Since you're using jQuery, try this one: jQuery Validation Plugin | Form validation with jQuery

    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