Abide detects error messages by looking for elements with the .form-error class that are siblings of the input or contained within the same parent.
Linking errors to inputs
If an error message cannot be a direct sibling (e.g., inside an Input Group), use the data-form-error-for attribute on the error element to link it to the input's id.
Validator-specific messages
You can provide different messages for different validation failures using the data-form-error-on attribute. Supported validator names include required, pattern, equalTo, and any custom validator names you define.
Summary of error attributes:
data-form-error-for="[input-id]": Links a non-sibling error message to an input.data-form-error-on="[validator-name]": Specifies which validation failure this message applies to.
<!-- Linking error to an input in an input group -->
<div class="input-group">
<span class="input-group-label">$</span>
<input class="input-group-field" id="amountInput" type="number" required />
</div>
<label class="form-error" data-form-error-for="amountInput">Amount is required.</label>
<!-- Specific messages for different errors -->
<input type="text" required pattern="email">
<span class="form-error" data-form-error-on="required">Email is required.</span>
<span class="form-error" data-form-error-on="pattern">Invalid email format.</span>