Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saulovenancio/f7bddcd4ca3bb95cd0edb6bcae63e6fb to your computer and use it in GitHub Desktop.
Save saulovenancio/f7bddcd4ca3bb95cd0edb6bcae63e6fb to your computer and use it in GitHub Desktop.
AEM Touch UI validation
var $input = $('.my-input-field'),
errorMessege = 'This field is required';
if ($input.willValidate()) {
$input.checkValidity(); // true
$input.validationMessage(); // ''
/* Set input field as invalid */
$input.setCustomValidity(errorMessage);
$input.checkValidity(); // false
$input.validationMessage(); // 'This field is required'
$input.updateErrorUI(); // displays red error icon
/* Set input field as valid */
$input.setCustomValidity(null);
$input.checkValidity(); // true
$input.validationMessage(); // ''
$input.updateErrorUI(); // removes red error icon
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment