Skip to content

Instantly share code, notes, and snippets.

@nateyolles
Last active July 25, 2018 20:30
Show Gist options
  • Save nateyolles/a2cf9fac791eb0b4b915 to your computer and use it in GitHub Desktop.
Save nateyolles/a2cf9fac791eb0b4b915 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