Skip to content

parseTime regex fix for special characters #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions jquery-ui-timepicker-addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ $.extend(Timepicker.prototype, {
if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);

if (withDate || !this._defaults.timeOnly) {
// the time should come after x number of characters and a space.
// x = at least the length of text specified by the date format
var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator + regstr;
// escape special regex characters in the seperator
specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g");
// start matching from the end where we know the length of the time format
regstr = this._defaults.separator.replace(specials, "\\$&") + regstr;
}

treg = timeString.match(new RegExp(regstr, 'i'));
Expand Down