Closed (fixed)
Project:
Clientside Validation
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
14 May 2012 at 12:31 UTC
Updated:
30 May 2012 at 15:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
attiks commentedI like the idea. We searched for a similar solution in the past, but couldn't find any proper solution. The major problem is that we either have to support all possible regexp one can write in PHP, or find a way to determine which need an AJAX callback.
Comment #2
kaidawai commentedunderstand this. thing is every regengine is slightly different. even different php versions are different.
that means you never get every possibility covered.
so for "user" provided regex there is allways a responsibility to test if they work. only with the js regex the difference is so huge that you have quite a hard time to find something that works even for simple things. additionaly you have differences between browsers.
so i would think that it is acceptable if very complicated regex need a second thought but easy to work a around(i asume people who create such complicated regex are able to do).
Comment #3
attiks commentedI think the only way to find out is to implement it as an optional feature: so AJAX callbacks standard, xregexp optional is the library is installed.
Patches are welcome ;p
Comment #4
kaidawai commentedmaybe, i have to think about the "optional" part.
a) a codehighliter module has the engine included.
i have to check which version. old versions conflict in rare occasions with jquery.
b) see how much effort it is to make it optional. (you need some checkbox in the configuration fe or something)
i get back too you in a couple of days.
:P
Comment #5
attiks commentedThe "optional" is to not force people to install it, don't worry about it too much if you can provide a patch I'm more than happy ;p
Comment #6
ramsegal commentedi think basically the module should support all the built-in rules of jquery validation plugin, that way there's no need to use ajax calls...am i wrong?
Comment #7
attiks commentedThis is about custom regular expressions, and the fact that regexp in PHP aren't compatible with regexp in javascript. For now we use a custom AJAX callback rule that does the check on the server side, the idea is to 'translate' the regular expressions from PHP to javascript, hence the need for a helper library.
Comment #8
kaidawai commenteda first try.
i tried to make it errortolerant and with as little changes to the existing code as posible.
a) additional checkbox in the admin form: default off. should do nothing without enabling it.
b) if and only if it is on it looks sites/all/libraries/ for a dir xregexp with the libs.
c) if it can't find it there it looks in the module dir for this folder.
d) if it still didn't find it it just does nothing. (user can add the library in a different way e.g. another drual modul that has - at least on such module exists!)
e) if it cant find the lib it falls back to standart ajax.
the ugly part: to be able to switch between the two functions without big changes in the code i created the two functions explicit in javascript. this function within a function. looks a little funny if one is not used to javascript functions turning up in the middle of the code. so at least i moved them to the front of the surrounding function.
patch is attached.
Comment #9
attiks commentedGreat work, i did some minor cleaning but it works great!
Pushed to latest dev version
Comment #10
attiks commentedOne small problem left: #1584902: can't load XRegExp twice in the same frame
Comment #11
kaidawai commentedsee comment there.