Validating forms with svalidate.js
In this recipe, we will utilize a small and useful jQuery plugin called svalidate.js. A demo of this plugin is available at http://s-validate.ipatieff.me. The GitHub repository can be found at https://github.com/SergeIpatyev/svalidatejs.
Getting ready
To get ready, let's grab the raw svd.js
available at https://raw.githubusercontent.com/SergeIpatyev/svalidatejs/master/svd.js. Next, we will put GitCDN.xyz
to work and obtain the link to use in our script tag: https://gitcdn.xyz/repo/SergeIpatyev/svalidatejs/master/svd.js
.
How to do it…
- Let's begin by adding the
script
tag toapp/partial/_js.ejs
:
<script src="https://gitcdn.xyz/repo/SergeIpatyev/svalidatejs/master/svd.js"></script>
- Next, let's add another line of code to the bottom of
_js.ejs
:
<%- partial("_recipe-06-13-js") %>
- Open the file titled
recipe06-13.ejs
and add the following code on line 15:
<form method="post"> <div class="form-group row"> <label for="inputCustom" class...