Monday, April 7, 2014

jQuery validation plugin example

URL: http://jqueryvalidation.org/

 $(document).ready(function() {
        $("#frm").validate({
            errorClass: 'error',
            rules: {
                name: {
                    required:true,
                    alphanumeric: true
                },
                email: {
                    required: true,
                    email: true
                },
                address: "required"
            },
            messages: {
                name:{
                    alphanumeric: "Alphanumeric charactors only...!"
                },
                email: {
                    required: "We need your email address to contact you",
                    email: "Your email address must be in the format of name@domain.com"
                }              
            }
        });
    });