Skip to content

Instantly share code, notes, and snippets.

@imanilchaudhari
Created December 6, 2017 07:30
Show Gist options
  • Save imanilchaudhari/24943d73717bf1e37d50c14606bd9eab to your computer and use it in GitHub Desktop.
Save imanilchaudhari/24943d73717bf1e37d50c14606bd9eab to your computer and use it in GitHub Desktop.
Yii2 add custom error message on form
jQuery("#{form-id}").yiiActiveForm("add",{
"id": "field-id",
"name": "{field-name}",
"container": ".field-{field-id}",
"input": "#{field-id}",
"error": ".help-block",
"validate": function(attribute, value, messages, deferred, $form) {
yii.validation.required(value, messages, {
"message": "{message}"
});
yii.validation.string(value, messages, {
"message": "{message}",
"max": 90,
"tooLong": "{tooLangMessage}",
"skipOnEmpty": 1
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment