How to jQuery validation in asp.net with c#

In this article, I am going to explain with an example how to create a " required and use a normalizer to trim its value before validating control in asp.net using data table with c#
    <!doctype html> <html> <head> <meta charset="utf-8"> <title>Makes "field" required and use a normalizer to trim its value
    before validating</title>
    <link rel="stylesheet" href="https://jqueryvalidation.org/files/demo/site-demos.css">
    </head>
    <body> <form id="myform"> <label for="field">Required: </label> <input class="left" id="field" name="field"> <br/> <input type="submit" value="Validate!"> </form> <script src="https://code.jquery.com/jquery-1.11.1.min.js"></script> <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery. validate.min.js"></script> <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additiona l-methods.min.js"></script> <script> jQuery.validator.setDefaults({ debug: true, success: "valid" }); $("#myform").validate({ rules: { field: { required: true, normalizer: function (value)
    { // Trim the value of the `field` element before // validating. this trims only the value passed // to the attached validators, not the value of // the element itself. return $.trim(value); } } } }); </script> </body> </html>




Post a Comment

0 Comments