Skip to content

Instantly share code, notes, and snippets.

@ankitkanojia
Created August 7, 2020 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ankitkanojia/72f799f8e837d3039fb0c3054097e70e to your computer and use it in GitHub Desktop.
Save ankitkanojia/72f799f8e837d3039fb0c3054097e70e to your computer and use it in GitHub Desktop.
To configure jquery validation
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.2/jquery.validate.js"></script>
function InitializeValidation() {
$('.reuiredInput').attr("required", "required")
$("#verificationSelfFormControl").validate({
rules: {
".reuiredInput": {
required: true
}
},
errorElement: 'span',
errorPlacement: function (error, element) {
if (element.attr("type") == "radio") {
element.parent().parent().parent().append(error);
} else {
element.parent().append(error);
}
}
});
jQuery.extend(jQuery.validator.messages, {
required: "Please fill this field",
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment