Skip to content

Instantly share code, notes, and snippets.

var cat = function(obj){
//this is where I copy all the attributes of the passed object to the constructure
for (attr in obj){
this[attr] = obj[attr];
}
//publice method
this.talk = function(){
console.log('meeow!!!');
};
};
@skeep
skeep / validator.js
Last active December 10, 2015 12:18
var validator = (function () {
function trim(str) {
return str.replace(/^\s+|\s+$/g, '');
}
function isEmail(field) {
if (field) {
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(field)) {
return false;