2012-10-03 23:38:55 +02:00
|
|
|
|
var disallowed_domains = ['gmail.com'];
|
2012-10-03 23:34:27 +02:00
|
|
|
|
|
|
|
|
|
function validate_email_domain(value, element, param) {
|
2012-09-25 22:58:59 +02:00
|
|
|
|
var splitted = value.split("@");
|
2012-10-03 23:34:27 +02:00
|
|
|
|
var domain = splitted[splitted.length - 1];
|
2012-10-03 23:38:55 +02:00
|
|
|
|
return $.inArray(domain, disallowed_domains) !== -1;
|
2012-10-03 23:34:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-03 23:43:25 +02:00
|
|
|
|
|
2012-10-03 23:34:27 +02:00
|
|
|
|
$.validator.addMethod("fromDomain", validate_email_domain,
|
2012-09-25 22:58:59 +02:00
|
|
|
|
"Please use your company email address to sign up. Otherwise, we won’t be able to connect you with your coworkers.");
|
|
|
|
|
|
2012-10-03 23:34:27 +02:00
|
|
|
|
$(function () {
|
2012-10-03 23:43:25 +02:00
|
|
|
|
$('#registration').validate({
|
|
|
|
|
errorElement: "p",
|
|
|
|
|
errorPlacement: function (error, element) {
|
|
|
|
|
error.appendTo(element.parent()).addClass('help-inline');
|
|
|
|
|
element.parent().parent().removeClass('success').addClass('error');
|
|
|
|
|
},
|
|
|
|
|
success: function (label) {
|
|
|
|
|
label.parent().parent().removeClass('error').addClass('success');
|
2012-10-04 17:05:34 +02:00
|
|
|
|
}
|
2012-10-03 23:43:25 +02:00
|
|
|
|
});
|
|
|
|
|
|
2012-09-25 22:58:59 +02:00
|
|
|
|
$("#email_signup").validate({
|
|
|
|
|
rules: {
|
|
|
|
|
email: {
|
|
|
|
|
required: true,
|
2012-10-03 23:34:27 +02:00
|
|
|
|
email: true
|
2012-09-25 22:58:59 +02:00
|
|
|
|
}
|
|
|
|
|
},
|
2012-10-03 23:43:25 +02:00
|
|
|
|
errorElement: "p",
|
|
|
|
|
errorClass: "validation-failed",
|
|
|
|
|
errorPlacement: function (error, element) {
|
|
|
|
|
$('#errors').empty();
|
|
|
|
|
element.parent().parent().removeClass('success').addClass('error');
|
|
|
|
|
error.appendTo("#errors")
|
2012-10-04 17:05:34 +02:00
|
|
|
|
.addClass("text-error");
|
2012-10-03 23:43:25 +02:00
|
|
|
|
},
|
|
|
|
|
success: function (label) {
|
|
|
|
|
label.parent().parent().removeClass('error').addClass('success');
|
2012-10-04 17:05:34 +02:00
|
|
|
|
}
|
2012-09-25 22:58:59 +02:00
|
|
|
|
});
|
|
|
|
|
});
|