I got this script
 $("#SocialSecurityNumber").attr("placeholder","YYYY-MM-DD-XXXX").blur(function () {
        var str = $('#SocialSecurityNumber').val();
        var res = /^([1-2]\d{3})\-([0-1][1-9])\-([0-3][0-9])\-([0-9]{4})$/.exec(str);
        var todays_date = new Date();
        var birth_date = new Date(res[1], res[2], res[3]);
        if (todays_date - birth_date > 565633905872) {
            $("#btn-activation").removeAttr('disabled');
            $("#SocialSecurityNumber").removeClass("input-validation-error");
        } else {
            $("#SocialSecurityNumber").attr("placeholder","Please enter date of birth as YYYY-MM-DD-XXXX").addClass("input-validation-error");
            $("#btn-activation").attr("disabled", "disabled");
        }
    });
});
Which will validate age, from input #SocialSecurityNumber However, when entering letters or other jibberish it doesnt validate at all and i get js error
Uncaught TypeError: Cannot read property '1' of null 
Could somone help me with how i can add so this script also validates incorrect characters? (when regex is not matched)
 
     
    