Skip to content
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

Outdated phpjs implementation #444

Closed
Nuranto opened this issue Apr 25, 2020 · 10 comments · Fixed by #445
Closed

Outdated phpjs implementation #444

Nuranto opened this issue Apr 25, 2020 · 10 comments · Fixed by #445
Labels

Comments

@Nuranto
Copy link

Nuranto commented Apr 25, 2020

after_or_equal / before_or_equal does not work with today keyword (before_or_equal:today). Probably with other keywords as well.
Error is :

jsvalidation.js:1047 Uncaught TypeError: string.replace is not a function.  Exception occurred when checking element date_of_birth, check the 'laravelValidation' method.

Probably the problem occurs on Before/After too ?

@bytestream bytestream added the bug label Apr 25, 2020
@bytestream
Copy link
Collaborator

Thanks @Nuranto

At a glance, I think because we're using such an old version of phpjs it doesn't support today. We'd need to upgrade to the latest version which looks more promising: https://github.com/kvz/locutus/blob/master/src/php/datetime/strtotime.js#L1066

The only issue is that there's quite a few uses of phpjs so the likelihood of something breaking is probable!

I'll take a PR which upgrades phpjs

@bytestream bytestream linked a pull request Apr 26, 2020 that will close this issue
@bytestream
Copy link
Collaborator

bytestream commented Apr 26, 2020

Check the linked PR @Nuranto

@spyrmp
Copy link

spyrmp commented May 19, 2020

I have the same problem in the after
image

@bytestream
Copy link
Collaborator

@spyrmpontinis that issue sounds different to what's described in this issue?

You're comparing against another field. This issue is regarding an outdated strtotime implementation so certain date keywords don't work correctly.

If that's not working, please try to debug and open a new issue.

@bytestream
Copy link
Collaborator

@Nuranto if I merge to master do you mind checking it?

@bert-w
Copy link

bert-w commented Jun 7, 2020

@bytestream thats not how git branches should work...

fwiw i just encountered this issue. I'm using the Laravel validation before_or_after:now. It causes an error in the escapeCssMeta function because it receives an array ["date"] instead of a string. Havent checked any further on what it's actually doing.

Error message:

// jsvalidation.js:1047:18

TypeError: string.replace is not a function.  Exception occurred when checking element , check the 'laravelValidation' method.

@bytestream
Copy link
Collaborator

@bytestream thats not how git branches should work...

dev-master is not stable, only releases are stable. As far as I'm concerned the functionality in the PR works but I would appreciate others confirming.

fwiw i just encountered this issue. I'm using the Laravel validation before_or_after:now. It causes an error in the escapeCssMeta function because it receives an array ["date"] instead of a string.

This sounds more related to #424 (comment) than this issue...

Please open a new issue with a full test case to replicate.

This issue is specifically an outdated phpjs implementation. Anything else pertaining to after_/before_ rules should be opened in another issue with minimal test cases.

@bytestream bytestream changed the title after_or_equal / before_or_equal not working with keywords Outdated phpjs implementation Jun 8, 2020
@garbinmarcelo
Copy link

I have the same problem in the after
image

Hello, did you solve it? I'm going through something similar, but with "after_or_equal"

@spyrmp
Copy link

spyrmp commented Dec 31, 2020

I have the same problem in the after
image

Hello, did you solve it? I'm going through something similar, but with "after_or_equal"

Hello , i did not fix it in frontend. I am doing the validation on save controller because the problem is on jquery.validate.js as you can see in the print screen on js debugger of firefox.

image

The problem is that jsvalidation.js in line 94 in rule "after" or "after_or_equals" in your case the element param[1] is array as you can see on my print screen.

image

So the jquery.vaidate.js on is trying to use replace function on array which is not exists. I hope i was helpfull . I wish you happy new year :)

@bytestream
Copy link
Collaborator

Please open a new issue if you can replicate on the latest version. #530 was very similar to what you describe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants