var sub2 = document.getElementById("fsubmit");
var testname = document.getElementById("your-name");
var testphone = document.getElementById("your-phone");
testname.addEventListener("focusout", ValidateIt);
testphone.addEventListener("focusout", ValidateIt);
sub2.disabled = true;
function ValidateIt()
{
var regExName = /^[a-zA-Z]+(([',. -][a-zA-Z ])?[a-zA-Z]*)*$/g;
var regExPhone = /^[0-9]+$/;
if (!testname.value.match(regExName))
{
console.log("Name Problem");
alert("You have entered an invalid Name! No Blanks, use alphabet & space only");
testname.focus();
}
else if(!testphone.value.match(regExPhone)){
console.log("Bad Phone");
alert("You have entered an invalid Phone No! Only 10 digit numbers allowed");
testphone.focus();
}
else{
sub2.disabled = false;
}
}
console.log("working2");