THE ART OF INSIGHT - Online Learning Experience
Welcome to TAOI Online Learning. As a purchaser or potential purchaser of The Art of Insight, you are eligible to take the free online learning course. Please enter your name and email address to start the course.
// <![CDATA[
(function() {
var $;
$ = jQuery;
$(function() {
var field_error, is_email, is_int, is_numeric, is_string, log, taoi, taoi_email, taoi_first_name, taoi_last_name, taoi_save, validate_field;
log = function(m) {
return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(m) : void 0 : void 0;
};
is_string = function(v) {
var rgx;
rgx = /^[a-zA-Z0-9\s.\-\@\!\#\$\%\^\&\*\(\)\+\=\{\[\}\]\|\_\`\~\;\:\'\"\,\.\/\<\>\?\\]+$/;
return rgx.test(v);
};
is_email = function(v) {
var rgx;
rgx = /^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i;
return rgx.test(v);
};
is_int = function(v) {
var rgx;
rgx = /(^-?\d\d*$)/;
return rgx.test(v);
};
is_numeric = function(v) {
var rgx;
rgx = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
return rgx.test(v);
};
validate_field = function(obj) {
var ret, val, vtype;
vtype = obj.data('validation-type');
val = $.trim(obj.val());
log("Validating " + obj + " with value " + val);
ret = false;
if (vtype === 'string') {
ret = is_string(val);
} else if (vtype === 'email') {
ret = is_email(val);
} else if (vtype === 'int') {
ret = is_int(val);
} else if (vtype === 'numeric') {
ret = is_numeric(val);
} else {
ret = true;
}
field_error(obj, ret);
return ret;
};
field_error = function(obj, valid) {
if (valid) {
obj.removeClass('error');
obj.parent().find('.error_msg').hide();
obj.addClass('valid');
} else {
obj.removeClass('valid');
obj.addClass('error');
obj.parent().find('.error_msg').show();
}
return obj;
};
taoi_save = ($('#taoi_save')).button();
taoi_first_name = ($('#taoi_first_name')).trigger('focus').change(function() {
if (($(this)).data('validation-event') === "change") {
return validate_field($(this));
}
}).blur(function() {
if (($(this)).data('validation-event') === "blur") {
return validate_field($(this));
}
}).focus(function() {
log(($(this)).data('validation-event'));
if (($(this)).data('validation-event') === "focus") {
return validate_field($(this));
}
});
taoi_last_name = ($('#taoi_last_name')).change(function() {
if (($(this)).data('validation-event') === "change") {
return validate_field($(this));
}
}).blur(function() {
if (($(this)).data('validation-event') === "blur") {
return validate_field($(this));
}
}).focus(function() {
log(($(this)).data('validation-event'));
if (($(this)).data('validation-event') === "focus") {
return validate_field($(this));
}
});
taoi_email = ($('#taoi_email')).change(function() {
if (($(this)).data('validation-event') === "change") {
return validate_field($(this));
}
}).blur(function() {
if (($(this)).data('validation-event') === "blur") {
return validate_field($(this));
}
}).focus(function() {
log(($(this)).data('validation-event'));
if (($(this)).data('validation-event') === "focus") {
return validate_field($(this));
}
});
return taoi = ($('#taoi')).submit(function(e) {
var em, fn, ln, ret;
ret = true;
fn = validate_field(taoi_first_name);
ln = validate_field(taoi_last_name);
em = validate_field(taoi_email);
if (fn && ln && em) {
ret = true;
} else {
e.preventDefault();
ret = false;
}
return ret;
});
});
}).call(this);
// ]]>