I have tried by using the below code but the error message disappears quickly
$(document).ready(function () {
$('form').submit(function () {
if ($("#first").val().match('^[a-zA-Z]{3,16}$')) {
alert("valid");
} else {
$("#error_msg").after("invalid");
}
})
})