Skip to content

Instantly share code, notes, and snippets.

@jamesmoss
Last active August 29, 2015 14:23
Show Gist options
  • Save jamesmoss/6ad430fccd4f199720f8 to your computer and use it in GitHub Desktop.
Save jamesmoss/6ad430fccd4f199720f8 to your computer and use it in GitHub Desktop.
First Great Western's crazy email validation for their on-train wifi service.
var lastchar = $(this).val().length-1;
var e=$(this).val();
var alpha = /[a-z]/;
if (lastchar<7 || !alpha.test(e) || e.indexOf('@') === -1 || e.indexOf('.') === -1 || e.charAt(0) == "."
|| e.charAt(0) == "@" || e.charAt(lastchar) == "." || e.charAt(lastchar) == "@" || e.indexOf("[email protected]")>-1
|| e.indexOf("[email protected]")>-1 || e.indexOf("[email protected]")>-1 || e.indexOf("@example.")>-1 || e.indexOf("donald@duck")>-1
|| e.indexOf("mickey@mouse")>-1 || e.indexOf("@crap.")>-1 || e.indexOf("@test.")>-1 || e.indexOf("@none.")>-1
|| e.indexOf("@222.")>-1 || e.indexOf("@2.")>-1 || e.indexOf("no@one.")>-1 || e.indexOf("@off.")>-1
|| e.indexOf("no@email.")>-1 || e.indexOf("no@spam.")>-1 || e.indexOf("fake@")>-1 || e.indexOf("@fake.")>-1) {
errors = true;
$(this).parent().addClass('validate-error');
$(this).parent().prepend('<span class="validation">' + $(this).data('validate-message') + '</span>');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment