Magic Icon Form Validation: Magic JavaScript

Quick Jump ↵

Usage

Add data-mjf="form_required" name="FORM_NAME" id="FORM_NAME" to your <form> tag.

Add data-mjf="field_required" id="FIELD_ID" to your field tags.

Add <script type="text/javascript">$m.wand.form_required = true;</script> inside your <body> tag.

Example


This field is required


This field is required



At least one option must be selected
This field is required


At least one option must be selected

* Radio Buttons



At least one radio button must be selected

* Checkboxes


At least one check box must be selected

* Radio Button

* Checkbox

Notes

Add <span class="field_error_msg_off" id="FIELD_ID_required_msg"><br>This field is required</span> under your form field if you'd like a message toggled on and off as necessary.

Add data-mjf_err_parent="PARENT_ID" to your form field to highlight a particular HTML element on error. Otherwise the field's parent node will be highlighted. This explains the visual differences above.

For validation to work on <select>, include something like <option value="">Please choose...</option> as the first option.

Fields that are disabled and/or readonly are not validated.

« Back to the main documentation