I'm adding some client-side validations using Jquery Validation plugin to some existing pages. https:// jqueryvalidation.org The validations are working perfectly. However, because the user wants all the fields centered, the validation messages appear centered.
Is it possible to keep the centered textbox inputs, but have the validation messages appear under the textbox and aligned where the textbox starts?
This is what I have so far showing the validations: 1
This is what I am trying to achieve with the validation message aligned with the textbox underneath it. 2
Here is some simple code that I am working with to get an idea on using the validations. The actual forms typically have 12-15 input fields, all centered.
I know the "center" tag is deprecated, but still trying to keep it for now, if possible.
<script src="https://jqueryvalidation.org/files/lib/jquery.js"></script>
<script src="https://jqueryvalidation.org/files/dist/jquery.validate.min.js"></script>
<script src="https://jqueryvalidation.org/files/dist/additional-methods.min.js"></script>
<script>
$(document).ready(function () {
$("#myForm").validate();
});
</script>
<style>
label.error {
display: block;
float: none;
color: red;
}
input { border: 1px solid black; }
input:focus { border: 1px solid black; }
input.error { border: 1px solid red; }
</style>
<center>
<form id="myForm" action="/SubmitSuccess.html">
<label>Input Number: </label>
<input type="text" name="input_number" data-rule-required="true" data-msg-required="Required field. Please enter 6 digits" size=10 maxlength=10 pattern="[0-9]{6}" data-msg-pattern="Please enter 6 digits" />
<br>
<label>Input Alpha: </label>
<input type="text" name="input_alpha" id="input_alpha" data-rule-required="true" data-msg-required="Required field. Please enter 6 uppercase characters" size=10 maxlength=10 pattern="[A-Z]{6}" data-msg-pattern="Must be 6 uppercase characters." />
<br><br>
Click Submit when complete<br>
<input type="submit" name="SUBMIT" value="SUBMIT" />
</form>
</center>
JFiddle - https://jsfiddle.net/4d3xgud9