So I'm using jQuery validation and have managed (despite some out of date documentation) to get a group of required radio boxes working. The problem is the plugin is appending the error label directly after the first radio (the first of that group that has the required class).
With this in mind is it possible to set a custom location for each error label?
For reference this is the HTML:
<tr>
<td width="200">
<label>Title2 *</label>
</td>
<td width="505">
>>> <label><input type="radio" class="required" name="Title2" value="Mr" /> <!-- ERROR APPEARS HERE -->Mr</label>
<label><input type="radio" class="required" name="Title2" value="Miss" />Miss</label>
<label><input type="radio" class="required" name="Title2" value="Mrs" />Mrs</label>
<label><input type="radio" class="required" name="Title2" value="Ms" />Ms</label>
<!-- I WANT ERROR LABEL HERE -->
</td>
</tr>
Scroll across on the line marked >>>
and you'll see the comment that shows there the plugin is putting the error label, just before the closing </td>
you'll see where I want the label to go.
Any help appreciated, Thanks.
remove(); $(". error"). removeClass("error"); It will be ok, when you need to validate it again.
Java scriptready(function() { $("#basic-form"). validate(); }); This is based on the assumption that you have already added the required JavaScript files. Adding those lines of JavaScript will make sure that your form is properly validated and shows all the error messages.
Definition of jQuery validate errorplacement. The jQuery validate errorplacement() function is used to customize the placement of an error message. This function is a built-in function in jQuery. These function changes the default behavior of the validation plugin to insert the error label after the input fields.
Form validation is a process of confirming the relevant information entered by the user in the input field. Here we will be validating a simple form that consists of a username, password and a confirmed password using jQuery.
Try adding the label tag where you want:
<label class="error" for="Title2" generated="true"></label>
The plugin will use this tag to display error
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With