<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
$(".pan").change(function () {
var inputvalues = $(this).val();
var regex = /([A-Z]){5}([0-9]){4}([A-Z]){1}$/;
if(!regex.test(inputvalues)){
$(".error").text("Invalid Pan No !");
// return regex.test(inputvalues);
}
else{
$(".error").hide();
}
});
});
</script>
PAN : <input type="text" class="pan">
<p style="color:red;" class="error"></p>
</body>
</html>