Hi!
I'm trying to validate a field in my webform step where it checks if the email ends with the domain of their website, but whatever i try it doesn't work.
Here's my code:
if (window.jQuery) {
(function ($) {
if (typeof (webFormClientValidate) != 'undefined') {
var originalValidationFunction = webFormClientValidate;
if (originalValidationFunction && typeof (originalValidationFunction) == "function") {
webFormClientValidate = function() {
originalValidationFunction.apply(this, arguments);
var email = $("#cr36b_epasts.text").val();
var domain = $("#cr36b_domeins.text").val();
if (email.endsWith(domain)) {
return true;
} else {
return false;
alert("email has to end with your domain.");
}
};
}
}
}(window.jQuery));
}
I've inserted this js in Webform->webform step->form options->custom js. Would appreciate help with this, even if it is some other way of validation that isnt JS.
I would also like to validate the domain input field to make sure that it isnt any generic email websites such as gmail, yahoo, Hotmail etc.