I encountered an issue with JSFiddle and I am having trouble figuring out the root cause. My aim is to validate an input using a regex pattern for a person's name.
$("document").ready(function() {
function validateForm() {
var userName = $("input[name=userName]").val();
var subject = $("input[name=subject]").val();
var message = $("input[name=message]").val();
if (/^[a-zA-Z ]{2,30}$/.test(userName)) {
alert("Your name is in the correct format");
} else {
alert("Your name can't contain numbers or special characters.");
}
}
})