@yaireo/validator
Advanced tools
Comparing version 3.3.8 to 3.3.9
{ | ||
"name" : "@yaireo/validator", | ||
"version" : "3.3.8", | ||
"homepage" : "https://github.com/yairEO/validator", | ||
"description" : "The Validator is cross-browser and will give you the power to use future-proof input types such as `tel`, `email`, `number`, `date`, `time`, `checkbox` and `url`", | ||
"_npmUser" : { | ||
"name" : "vsync", | ||
"email" : "vsync.design@gmail.com" | ||
"name": "@yaireo/validator", | ||
"version": "3.3.9", | ||
"homepage": "https://github.com/yairEO/validator", | ||
"description": "The Validator is cross-browser and will give you the power to use future-proof input types such as `tel`, `email`, `number`, `date`, `time`, `checkbox` and `url`", | ||
"_npmUser": { | ||
"name": "vsync", | ||
"email": "vsync.design@gmail.com" | ||
}, | ||
"author" : { | ||
"name" : "Yair Even-Or", | ||
"email" : "vsync.design@gmail.com" | ||
"author": { | ||
"name": "Yair Even-Or", | ||
"email": "vsync.design@gmail.com" | ||
}, | ||
"main" : "validator.js", | ||
"repository" : { | ||
"type" : "git", | ||
"url" : "git+https://github.com/yairEO/validator.git" | ||
"main": "validator.js", | ||
"files": [ | ||
"validator.js" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/yairEO/validator.git" | ||
}, | ||
"bugs" : { | ||
"bugs": { | ||
"url": "https://github.com/yaireo/validator/issues" | ||
} | ||
} |
@@ -38,3 +38,3 @@ <h1 align="center"> | ||
✔️ `email` <br/> | ||
✔️ `password` (also comparing "re-type password" inputs<br/> | ||
✔️ `password` - also comparing "re-type password" inputs<br/> | ||
✔️ `number` <br/> | ||
@@ -50,3 +50,3 @@ ✔️ `date` <br/> | ||
✔️ `textarea`<br/> | ||
✔️ `hidden` – Hidden fields can also have the ‘required’ attribute | ||
✔️ `hidden` – can also have the ‘required’ attribute | ||
@@ -53,0 +53,0 @@ |
@@ -61,3 +61,3 @@ /* | ||
texts : { | ||
invalid : 'inupt is not as expected', | ||
invalid : 'input is not as expected', | ||
short : 'input is too short', | ||
@@ -110,7 +110,7 @@ long : 'input is too long', | ||
else | ||
return true; | ||
return true | ||
}, | ||
hasValue : function( value ){ | ||
return value ? true : this.texts.empty; | ||
return value ? true : this.texts.empty | ||
}, | ||
@@ -122,13 +122,18 @@ | ||
// choose a specific message or a general one | ||
return this.texts[type + '_repeat'] || this.texts.no_match; | ||
return this.texts[type + '_repeat'] || this.texts.no_match | ||
} | ||
return true; | ||
return true | ||
}, | ||
email : function(field, data){ | ||
if ( !this.settings.regex.email.filter.test( data.value ) || data.value.match( this.settings.regex.email.illegalChars ) ){ | ||
return this.texts.email; | ||
} | ||
var i, emails = data.value.trim().split(' ') | ||
return true; | ||
if( !field.multiple && emails.length > 1 ) | ||
return this.texts.email | ||
for( var i = 0; i < emails.length; i++ ) | ||
if ( !this.settings.regex.email.filter.test( emails[i] ) || emails[i].match( this.settings.regex.email.illegalChars ) ) | ||
return this.texts.email | ||
return true | ||
}, | ||
@@ -304,4 +309,5 @@ | ||
formElm.addEventListener(type, function(e){ | ||
that.checkField(e.target) | ||
}, true); | ||
// a timeout is needed because on paste event the new value will not be available right away | ||
setTimeout(that.checkField.bind(that), 0, e.target) | ||
}, true) | ||
} | ||
@@ -413,4 +419,4 @@ }, | ||
this.data[id].valid = true; // initialize validity of field | ||
this.data[id].type = field.getAttribute('type'); // every field starts as 'valid=true' until proven otherwise | ||
this.data[id].pattern = field.getAttribute('pattern'); | ||
this.data[id].type = field.type; // every field starts as 'valid=true' until proven otherwise | ||
this.data[id].pattern = field.pattern; | ||
@@ -613,2 +619,2 @@ // Special treatment | ||
return FormValidator; | ||
})); | ||
})); |
38209
3
506