Business Emails ONLY

Email form field validation to message not to use Non-Business email clients

by Thomas Orthbandt

HTML

<script src="https://jqueryvalidation.org/files/dist/jquery.validate.js"></script>
<form id="mktoForm_1352" novalidate="novalidate" class="mktoForm mktoHasWidth mktoLayoutAbove">
  <div class="mktoFormRow">
    <div class="mktoFieldDescriptor mktoFormCol" style="margin-bottom: 10px;">
      <div class="mktoOffset" style="width: 10px;"></div>
      <div class="mktoFieldWrap mktoRequiredField">
        <label for="email" class="mktoLabel mktoHasWidth" style="width: 260px;">
          <div class="mktoAsterix">*</div>
          Email Address (Business email only)
        </label>
        <div class="mktoGutter mktoHasWidth" style="width: 10px;"></div>
          <input type="text" name="email" id="email" placeholder="email" maxlength="255" class="mktoField mktoTextField mktoHasWidth mktoRequired mktoInvalid" style="width: 260px;">
        <div class="mktoClear"></div>
      </div>
      <div class="mktoClear"></div>
    </div>
    <div class="mktoClear"></div>
  </div>
</form>

CSS

.mktoFormRow:not(:last-child) {
    margin-bottom: 1em;
}
.mktoForm .mktoFormRow {
    clear: both;
}
.mktoForm div, .mktoForm span, 
.mktoForm label, .mktoForm p {
    text-align: left;
    margin: 0;
    padding: 0;
}
.mktoForm .mktoLabel {
    float: left;
    line-height: 1.2em;
    padding-top: 0.3em;
}
.mktoForm .mktoFormCol {
    float: left;
    position: relative;
    min-height: 2em;
}
.mktoForm .mktoOffset {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}
.mktoForm .mktoOffset, 
.mktoForm .mktoFieldWrap {
    float: none !important;
}
.mktoForm .mktoRequiredField label.mktoLabel {
    font-weight: bold;
}
.mktoForm.mktoLayoutAbove .mktoLabel {
    text-align: left;
}
.mktoForm label.mktoLabel {
    font-size: 12px;
    color: #aeaeae;
    text-transform: uppercase;
    margin-bottom: 10px;
}
.mktoForm label.mktoLabel, 
.mktoForm.mktoLayoutAbove .mktoField {
    width: 100% !important;
}
.mktoForm.mktoLayoutAbove .mktoRequiredField .mktoAsterix {
    float: left;
    padding-left: 0;
    padding-right: 5px;
}
.mktoForm .mktoRequiredField .mktoAsterix {
    display: inline-block;
}
.mktoForm .mktoAsterix {
    color: #bf0000;
}
.mktoForm.mktoLayoutAbove .mktoGutter {
    display: none;
}
.mktoForm .mktoGutter {
    float: left;
    height: 1.2em;
}
.mktoForm label.mktoLabel, .mktoForm.mktoLayoutAbove .mktoField {
    width: 100% !important;
}
.mktoForm.mktoLayoutAbove .mktoField, .mktoForm.mktoLayoutAbove .mktoLogicalField {
    clear: left;
}

JavaScript

$(function() {
	var nobizemail = []
   $.validator.addMethod('nobizemail', function (value) { 
      return /^([\w\W]+@(?!gmail\.com)(?!Gmail\.com)(?!GMAIL\.com)(?!yahoo\.com)(?!Yahoo\.com)(?!YAHOO\.com)(?!hotmail\.com)(?!Hotmail\.com)(?!HOTMAIL\.com)(?!aol\.com)(?!AOL\.com)(?!msn\.com)(?!MSN\.com)([\w\W]+.)+[\w-]{2,4})?$/.test(value);
   });

   // validate signup form on keyup and submit
		$("form").validate({
			rules: {
				email: {
					required: true,
         	nobizemail: true,
          email: true
				}
			},
			messages: {
				email: {
					required: "<p>Please enter an email address</p>",
         	nobizemail: "<p>Please enter your business email",
          email: "<p>Please enter a valid email address</p>"
				}
			}
		});
});