Reputation: 61
I have a registration page that uses Dojo & Dijit forms with client-side validation, e.g.
<input style="width: 220px;" type="email" name="email" id="email" placeholder="your email address" required="true" maxLength="78" dojo-data-id="email" intermediateChanges="true" dojoType="dijit.form.ValidationTextBox" regexp="<?php echo EMAIL_REGEX;?>"></input>
This all works fine, except that if the user clicks on a link without having touched the form (i.e. navigates away), the input field that is currently focused briefly turns 'invalid' i.e. gets a red '!' tooltip.
This is not disastrous but slightly annoying - is there any way to prevent it? I've tried adding an onUnload event but this seems to trigger after the field is marked invalid.
Upvotes: 0
Views: 281
Reputation: 21
I believe this is as a consequence of you marking the field with required="true"
If you still wish these fields to be required, but don't want this bug to happen, I'd suggest, setting them as not required and then connecting to your dijit form's onsubmit event. In there, I'd set all the necessary fields required=true's and then validate the form. If the form contains invalid fields, prevent the form from submitting.
Upvotes: 1