Form validation works in simple 2 steps
To make a filed required simply add val-type="text" attribute to your html
for different type of form element we have differnt val-types as follows...
Element Type | Val-Type |
---|---|
input [type=text,email,date,number] textarea |
val-type="text" |
input [type=file] | val-type="file" |
input [type=radio] | val-type="radio" |
input [type=checkbox] | val-type="check" |
select | val-type="select" |
To display error we need to add a < span class="help-block" >
If the span block is not sibling of the element we want to validate then we need to add an additional attribute with-parent="yes"
For Regualr Expression, you simply need to add one more additional attribute regex="email"
and in verifyInput($input, $type){...} you need to specify email regex as shown below
Give Id to your form and the submit button
Once you are done, you just need to call the formValidator