Skip to content

Instantly share code, notes, and snippets.

@imamabudaud
Created May 1, 2013 11:41
Show Gist options
  • Save imamabudaud/5494865 to your computer and use it in GitHub Desktop.
Save imamabudaud/5494865 to your computer and use it in GitHub Desktop.
Javascript: Add class to required input from jQuery validate
function markRequiredField(form_id){
var rules = $('#'+form_id).validate().settings.rules;
$.each(rules, function(input) {
if (rules[input].hasOwnProperty("required") && rules[input].required == true){
$('input[name="'+input+'"]').addClass("requiredClass");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment