I have posted a feature request https://tracker.zkoss.org/browse/ZK-4863
hawk ( 2021-04-15 11:49:43 +0800 )edit-
FEATURED COMPONENTS
First time here? Check out the FAQ!
See Fiddle_Example
Is it possible to set the flags for a constraint regex?
I want to do something like
/^[\p{L}\p{P}\p{Z}\p{N}\|]{1,32}$/gmu
the /gmu (specifically the "u") are the flags to (hopefully) tell javascript to treat the \p{L} etc as tests for Unicode characters.
It is all to test that a name is valid including umlauts etc.
It does not work and is using the older regex that has no special meaning for \p{L}
Thanks for pointing me in the right direction.
Unfortunately I don't see it ever working unless the ZK SimpleConstraints.js is changed (either by Potix or my own version) as the option flag set by the JS is only the "g" flag. The SimpleConstraints JS simply ignores any supplied flag information (after the final "/") and uses a fixed "g" flag.
this._regex = new RegExp(k >= 0 ? cst.substring(j, k) : cst.substring(j), 'g');
Ideally Potix should accept a change request to support Regexp flags.
There is a possible alternative that does mostly what I want -
Use
inputAttributes="pattern=^[\p{L}\p{P}\p{Z}\p{N}\|]{1,32}$"
on the ZUL. You also need :
input:invalid { background-color: #ffdddd; }
in your CSS.
However as I need anyway to do further validation, I will do all validation at server and show error message as appropriate.
I have posted a feature request https://tracker.zkoss.org/browse/ZK-4863
hawk ( 2021-04-15 11:49:43 +0800 )editAccording to your example, it uses javascript regular expression to validate.
ZK just calls new RegExp() and validate your input with val.match(regex)
.
Therefore, what ZK supports is what a browser can support.
You can check the related source:
You can also override that function like
zk.afterLoad('zul.inp', function() {
var exWidget = {};
zk.override(zul.inp.SimpleConstraint.prototype, exWidget, {
_init: function (cst) {
exWidget._init.apply(this, arguments);
if (this._regex){
//create your own RegExp
}
},
});
});
Asked: 2021-04-13 21:00:44 +0800
Seen: 17 times
Last updated: Jul 13 '21
bug with intboxes on mobile devices
zk keikai-how to add custom button/label to formulabar?
zk-keikai- update multiple cells parallel at same time asynchronously
zk-keikai-How to auto fit column width based on text
zk-keikai-ClipboardPateEvent-called twice
Reference a spring bean from VariableResolver
Thanks for pointing me in the right direction.
Bobzk ( 2021-04-14 19:15:02 +0800 )edit