Sunday, January 5, 2014

Best Practices : HTML Forms validation

Use Jquiry based validation plugin.

download from :
http://bassistance.de/jquery-plugins/jquery-plugin-validation/

CDN:
http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js


 Sample code used by me:

   $("#form").validate({
            rules: {
                email: {
                    required: true,
                    email: true,
                    remote: {
                        url: "<?php echo HTTP_SERVER."ajax/dup_user_id_check.php";?>",
                        type: "post"
                     }
                }
               
            },
            messages: {
                email: {
                    required: "Please Enter Email!",
                    email: "This is not a valid email!",
                    remote: "Email already in use!"
                }
            }
        });

No comments:

Post a Comment