-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Set Date to null if character entered is non alpha numeric instead of 31 December 1899 #434
base: master
Are you sure you want to change the base?
Set Date to null if character entered is non alpha numeric instead of 31 December 1899 #434
Conversation
8787091
to
15019f3
Compare
👍 |
2b5d425
to
aa66c88
Compare
@davidpatters0n Could you explain the regex to me briefly, please? Thanks! |
61a2491
to
8180c81
Compare
@AuspeXeu the regex will match characters that are numeric and followed by a hyphen followed by another number more than 1 or more times. |
@davidpatters0n So this is format specific as it requires the user to use hyphens. Is that correct? |
Correct. As shown in the above gif in the description you'll see that entering a hyphen in this instance will cause the date to be set |
But wouldn't it make sense to have it tolerate different date formats? Maybe even rely on the format that is currently set for the component? |
That is correct. As shown below, i ran the regex against a series of different date formats and it seems to comply. !(/^(\d+-?|\d+\/?|.)+\d.*/).test('2015-04-05')
false
!(/^(\d+-?|\d+\/?|.)+\d.*/).test('05-04-2015')
false
!(/^(\d+-?|\d+\/?|.)+\d.*/).test('05/04/2015')
false
!(/^(\d+-?|\d+\/?|.)+\d.*/).test('2015/04/05')
false
!(/^(\d+-?|\d+\/?|.)+\d.*/).test('-')
true
!(/^(\d+-?|\d+\/?|.)+\d.*/).test('?')
true
!(/^(\d+-?|\d+\/?|.)+\d.*/).test('^')
true |
And I also think maybe it would be a good idea for it to rely based on the format of the what is currently set for the component. |
Couldn't we use the format setting to generate a regex from that, what do you think? |
👍 |
1 similar comment
👍 |
10cc56b
to
591df69
Compare
@AuspeXeu - The tests on Travis are going to continue to fail because of this PR: #571 - As mentioned in the comment for that PR i have opened a separate PR that addresses this too. WRT to your comment:
I didn't need to do this because I made use of: |
591df69
to
df971e4
Compare
The purpose of this pull request is to address the potential affect of entering a non alpha-numeric which sets the date back to 31 December 1899 as shown
This change simply matches against any single non alpha-numeric character and returns
null
. Example shown