Reputation: 2234
Its not working. I don't know regEx, but I need use it.
if ($('input[name="due_date"]').val().match("^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\\d\\d$")) {
$('input[name="due_date"]').after("<span class='v_error'>Must fill</span>");
}
Upvotes: 2
Views: 4620
Reputation: 958
You're trying to match with the HTML object, you might add .val() after the jQuery Selector, like
$('input[name="due_date"]').val().match(/^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\\d\\d$/);
Upvotes: 1
Reputation: 15853
A regex is surrounded with slashes. I just found that your regex is incorrect, too... So, coupled with the jQuery error pointed out by xdazz:
$('input[name="due_date"]').val().match(/^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$/);
The regex is from this website.
Upvotes: 2