I am using foundation css for front end design and how can I use Abide(form validator).
Example:.. If I need to allow only 10 characters for the field Phone number..
Correct me If I am wrong as I am a newbie to use foundation and web dev.
I have already tried doing this... this does not work..
version : '5.3.3',
settings : {
live_validate : true,
focus_on_invalid : true,
error_labels: true, // labels with a for="inputId" will recieve an `error` class
timeout : 1000,
patterns : {
alpha: /^[a-zA-Z]+$/,
alpha_numeric : /^[a-zA-Z0-9]+$/,
integer: /^[-+]?\d+$/,
// modified here
cvv : /^([0-9]){3,4}$/, \\ I have just copied the above line and renamed the pattern as "cv"
cv : /^([0-9]){3,4}$/' \\the pattern cvv works but the same when I copy pasted and renamed to cv does not work.
`
I would start by looking at their documentation (here: http://foundation.zurb.com/docs/components/abide.html)
there you will learn how to add a custom pattern (since you have some custom requirements).
You will have to define a new pattern, maybe call it phoneNumber
$(document)
.foundation({
abide : {
patterns: {
phoneNumber: ^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$ //this matches (111) 222-3333 | 1112223333 | 111-222-3333
}
}
});
once you have defined your pattern you can go ahead and use it:
<form class="custom" data-abide>
<label>Phone Number
<input type="text" pattern="phoneNumber" required>
</label>
</form>
Here's a link to another useful site when in need of RegExp: http://regexlib.com/Search.aspx?k=phone+number&c=-1&m=-1&ps=20 - if you would like to match a different format take a look there.