<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".gst").change(function () {
var inputvalues = $(this).val();
var gstinformat = new RegExp('^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]1}[1-9A-Z]{1}Z[0-9A-Z]{1}$');
if (gstinformat.test(inputvalues)) {
return true;
alert();
} else {
alert('Please Enter Valid GSTIN Number');
$(".gst").focus();
}
});
});
</script>
</head>
<body>
GST Number
<input type="text" class="gst" >
</body>
</html>