Skip to content

Instantly share code, notes, and snippets.

@mrmason
Created April 4, 2011 23:02
Show Gist options
  • Save mrmason/902659 to your computer and use it in GitHub Desktop.
Save mrmason/902659 to your computer and use it in GitHub Desktop.
var nameserver = /^((([a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?\.)+[a-z]{2,6})|(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))$/i;
$('#configure_domains_form').submit(function() {
$('input[name^="domainns"]').each(function(){
if(nameserver.test($(this).val())){
// Do nothing
}
else{
if ($(this).val() == ""){
if($(this).attr("name") == "domainns3" || $(this).attr("name") == "domainns4"){
// Do nothing, it's ok for these to be Blank
}
else{
alert($(this).attr("name") + ": Cannot be blank - you need 2 Nameservers. If in doubt, please use n1.krystal.co.uk and ns2.krystal.co.uk");
return false;
}
}else{
alert($(this).val() + " is not a valid nameserver : " + $(this).attr("name"));
return false;
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment