Thymleaf form with validator.js

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Thymleaf form with validator.js

jguidoux
Hello every one

I'm using validator.js from boottrap to create a register page.
my register page is very close of the exemple of the page : validator.js

In the server side, I'm using spring mvc. I would like to display an error when an email already exist.
In this case I would like that the input-group is marked as error with the error message.
Exactly the same as validator.js do when the email address is not well formatted.

This is the actual thymeleaf code to display the email input
<form id="form" class="" th:action="@{/signup}" method="post"
                          th:object="${user}"
                          data-toggle="validator">

...

                        <div class="form-group has-feedback">
                            <label for="email" class="cols-sm-2 control-label">Your Email</label>
                            <div class="input-group">
                                <span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
                                <input id="email" type="email" class="form-control" name="email"
                                       placeholder="Enter your Email" th:field="*{email}"/>
                            </div>
                            <span class="glyphicon form-control-feedback" aria-hidden="true"></span>
                            <div class="help-block with-errors"></div>
                        </div>

…
</form>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.9/validator.js"></script>


How can do that without being in conflict with validator.js which works well ?
I hope I explain well my problem.

Thanks :)