I have a field in my form. That field has to accept multidates, for that I am using:
$("#myInput").datepicker({
format: "dd/mm/yyyy",
multidate: true,
templates: {
rightArrow: '>',
leftArrow: '<'
}
});
<input type="text" id="myInput" name="myInput" placeholder="DD/MM/YYYY" class="form-control" autocomplete="off">
It works great, but I would like to prevent the user to input some illegal character with some regex pattern
.
I’ve found some alphanumeric
examples, but could not find an example for multidate. The idea is accepting numbers [0-9]
and the characters ","
and "/"
only.
I also found this example for a single date, and I tried it but it did not work for multiple dates:
^(0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)dd$
The accepted format is this: DD/MM/YYYY,DD/MM/YYYY,DD/MM/YYYY
E.g.
23/01/2022,25/01/2022,27/01/2022