Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to show a alert message or show a div on form submit

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #171338
    sshuvro58
    Participant

    I am using this to validate a form . I want to show a alert message or a div upon form submit .

    The submission process is going here

    submitHandler: function(form) {
    
                        form.submit();
    
                    }
     How can I modify this code to accomplish my task . 
    

    Here is my full validation code

    (function($,W,D)
    {
                  $.validator.setDefaults({
        submitHandler: function() { alert("submitted!"); }
                  });
            $("#refreshimg").click(function(){
            $.post('newsession.php');
            $("#captchaimage").load('image_req.php');
            return false;
        });
        var JQUERY4U = {};
    
        JQUERY4U.UTIL =
        {
            setupFormValidation: function()
            {
                //form validation rules
                $("#registration").validate({
                    rules: {
                        fullname: "required",
                        captcha: {
                    required: true,
                    remote: "process.php"
                },
    
                        email:
                        {
                        required: true,
                        email: true,
                        "remote":
                        {
                          url: 'check.php',
                          type: "post",
                          data:
                          {
                              email: function()
                              {
                                  return $('#registration :input[name="email"]').val();
                              }
                          }
                        }
                        },
                        password: {
                            required: true,
                            minlength: 5
                        },
                        confirm_password: {
                    required: true,
                    minlength: 5,
                    equalTo: "#password"
                },
                        terms: "required"
                    },
                    messages: {
                        firstname: "Please enter your firstname",
                        lastname: "Please enter your lastname",
                        password: {
                            required: "Please provide a password",
                            minlength: "Your password must be at least 5 characters long"
                        },
                        email:
                        {
                        required: "Please enter your email address.",
                        email: "Please enter a valid email address.",
                        remote: jQuery.validator.format("{0} is already taken.")
                        },
                        terms: "Please accept our policy",
                        captcha: "Correct captcha is required. Click the captcha to generate a new one"
                    },
                    submitHandler: function(form) {
    
                        form.submit();
    
                    }
                });
            }
    
        }
    
        //when the dom has loaded setup form validation rules
        $(D).ready(function($) {
            JQUERY4U.UTIL.setupFormValidation();
        });
    
    })(jQuery, window, document);
    
    #171359
    shaneisme
    Participant

    In the docs it gives you a method to know when a form is valid:

    http://jqueryvalidation.org/valid

    You should be able to modify that to append/show/etc. what you need.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.