JSFiddle - React, Tailwind, and code Playground
by jquerybyexample
HTML
Enter Date : <input type='text' id='txtDate' maxlength="7"/> (MM/YYYY)
CSS
body
{
padding: 10px;
font-family: Arial;
Font-size: 10pt;
}
JavaScript
$(document).ready(function() {
$('#txtDate').blur(function() {
if(validateDate('txtDate'))
{
alert('Date is valid');
}
else
{
alert('Invalid Date!!!');
}
});
});
function validateDate(txtDate){
var txtVal = document.getElementById(txtDate).value;
var filter = new RegExp("(0[123456789]|10|11|12)([/])([1-2][0-9][0-9][0-9])");
if(filter.test(txtVal))
{
return true;
}
else
{
return false;
}
}