JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://ajax.microsoft.com/ajax/jquery.validate/1.6/jquery.validate.min.js"></script>
<form id="myform">
    <input type="text" name="foo" />
    <button type="submit">OK</button>
</form>

JavaScript

$.validator.addMethod(
    "regex",
    function(value, element, regexp) {
        var re = new RegExp(regexp);
        return re.test(value);
    },
    "Please check your input."
);

$('#myform').validate({
    rules: {
        foo: {
            regex: '^[0-9]{6}-[0-9]{4}$'
        }
    },
    messages: {
        foo: {
            regex: 'Please provide a valid input for this field'
        }
    }
});