fixed broken regular expression for multiple comma-separated values (dash in character class has to be last character!)

This commit is contained in:
Ralf Becker 2014-07-13 09:14:58 +00:00
parent 8c6ac14093
commit f011a6c3d1
2 changed files with 15 additions and 5 deletions

View File

@ -291,7 +291,7 @@ var et2_selectAccount = et2_selectbox.extend(
*/
set_value: function(_value)
{
if(typeof _value == "string" && this.options.multiple && _value.match(/^[,0-9A-Za-z/-_]+$/) !== null)
if(typeof _value == "string" && this.options.multiple && _value.match(this._is_multiple_regexp) !== null)
{
_value = _value.split(',');
}

View File

@ -423,10 +423,20 @@ var et2_selectbox = et2_inputWidget.extend(
this.set_select_options(this.options.select_options);
},
/**
* Regular expression, to check string-value contains multiple comma-separated values
*/
_is_multiple_regexp: /^[,0-9A-Za-z/_-]+$/,
/**
* Set value
*
* @param _value
*/
set_value: function(_value)
{
if (typeof _value == "number") _value = ""+_value; // convert to string for consitent matching
if(typeof _value == "string" && this.options.multiple && _value.match(/^[,0-9A-Za-z/-_]+$/) !== null)
if(typeof _value == "string" && this.options.multiple && _value.match(this._is_multiple_regexp) !== null)
{
_value = _value.split(',');
}
@ -915,7 +925,7 @@ var et2_selectbox_ro = et2_selectbox.extend([et2_IDetachedDOM],
if(typeof _value == "string")
{
_value = _value.match(/^[,0-9A-Za-z]+$/) !== null ? _value.split(',') : [_value];
_value = _value.match(this._is_multiple_regexp) !== null ? _value.split(',') : [_value];
}
this.span.empty();