I would like to display a custom alert, rather than simply true or false. I have:
function isValid(test) {
return /^[a-zA-Z]{2}(?:\d{6}|\d{8}|\d{10})$/.test(test);
}
function checkValid(){
var userEntry = document.getElementById("entry1").value;
alert(isValid(firstRef));
}
So depending on whether what the user is valid or not they get the message "true" or "false". I would like the user to get a customised message if their input returns false such as "Invalid format try again" and get no message displayed when they input the correct data. Could I somehow use an if statement along the lines of if true then.... else...?