comma breaks regular expression form validate


I am trying to validate an input parameter of a form with a regular expression but encounter and error in the dhtmlform.js. I am very new to this and was hoping someone could help me understand where I am going wrong…

{type: “input”, name: ‘backupDest’, labelWidth :150, position: “label-left”, label: ‘* Backup Destination:’, value: backupDest, validate:"[^|%&,]"}

The regular expression works great until I add the comma. I am trying to exclude 4 characters from the input including a comma. I have tried escaping the comma with a backslash with no luck as well.

line 613 in dhtmlxform.js

invalid range in character class
[Break On This Error]

…&& (typeof(f)==“function”?f(val):new RegExp(this.itemPull[a]._validate[q]).test(…


yes :frowning:

it try to do validate_rule.split(",") to check if there more that 1 rule.

try this:

{type: “input”,… validate: function(value){return(value.match(/…your regexp…/)!=null);} }


Thanks for the code! The inline match seems to fix the issue with the comma, but I still have an issue where the validate:function(value) doesn’t seem to be happy with the return type.

if I do validate:false it evaluates correctly, but when the value.match() returns false, validate acts as if I passed true. It there something that causes it to be treated as a string?


upon further investigation, it appears that the function does not get executed?

Trying this a couple ways I could never get the function to execute…

{type: “input”, … validate:function(value){console.log("Value: " + value); return false;}}, // no log is printed

Also tried breaking out the function as shown in the help files…
{type: “input”, … validate:“noIllegalChars”},

noIllegalChars: function(paramValue) {
console.log("Value: " + paramValue); // again no log
return false;


I can get a function to execute with the following syntax but the “value” is undefined…

{…, validate:noIllegalChars(value)}

Can anyone guide me to the proper syntax to execute a function via the form validate and have the current field value passed in?



please provide completed demo including js/css to reproduce issue localy


Ended up changing other code to no longer need to omit the comma.

If I get some time, I will put together a demo for reproducing the issue I saw.

Thank you so much for your help.



Maybee I found a solution : use the hexadecimal encoding (or other js regex compatible encoding) for comma : \x2C

Which give : validate:"[^|%&\x2C]"

Works for me.