• Jquery form validation in PHP

    Kindly find below code for Jquery form validation in PHP.

    1. The CSS.

    2. The Javascript

    View Code JAVASCRIPT
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script><script type="text/javascript" src="http://jquery.bassistance.de/validate/jquery.validate.js"></script><script type="text/javascript">// <![CDATA[
    /**
    * Basic jQuery Validation Form Demo Code
    * Copyright Sam Deering 2012
    * Licence: http://www.jquery4u.com/license/
    */
    (function($,W,D)
    {
    var JQUERY4U = {};
     
    JQUERY4U.UTIL =
    {
    setupFormValidation: function()
    {
    //form validation rules
    $("#register-form").validate({
    rules: {
    firstname: "required",
    lastname: "required",
    email: {
    required: true,
    email: true
    },
    password: {
    required: true,
    minlength: 5
    },
    agree: "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: "Please enter a valid email address",
    agree: "Please accept our policy"
    },
    submitHandler: function(form) {
    form.submit();
    }
    });
    }
    }
     
    //when the dom has loaded setup form validation rules
    $(D).ready(function($) {
    JQUERY4U.UTIL.setupFormValidation();
    });
     
    })(jQuery, window, document);
    // ]]></script>

    3. The HTML

    Basic jQuery Validation Form Demo


    User Registration





Comments on this post

Leave a Reply

  • Security Code :


    six − 2 =