My brain's getting fried! lol I may have to submit what I have with questions to my instructor and hope he gets back to me in time to get it figured out and turned in on time on Sunday. Seems like plenty of time, but for some reason online instructors aren't "online" much!
Oh. Wow. I got that straight from the w3schools.com site!
You should be aware that the w3schools site is now very much out of date. As felgall says, it teaches 20th century Javascript.
Code:
<input type="text" id="custName" name="custName" onblur="validateName(this);">
<script type = "text/javascript">
function validateName (which) {
var val = which.value;
val = val.replace(/[^a-z\s\-]gi, ""); // strip all but letters (ignore case) and hyphens and spaces - Mary-Lou Smith
which.value = val; // write it back to the field
if (val.length < 4) {
alert ("Your name must have at least 4 alpha characters");
which.focus(); // refocus on the incorrect field so compelling the user to make a valid entry
return false;
}
}
</script>
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.