mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[ADD] web_widget_pattern (#458)
This commit is contained in:
committed by
Pedro M. Baeza
parent
117bd53966
commit
1e374d6644
24
web_widget_pattern/static/src/js/web_widget_pattern.js
Normal file
24
web_widget_pattern/static/src/js/web_widget_pattern.js
Normal file
@@ -0,0 +1,24 @@
|
||||
//-*- coding: utf-8 -*-
|
||||
//© 2016 Therp BV <http://therp.nl>
|
||||
//License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
openerp.web_widget_pattern = function(instance)
|
||||
{
|
||||
instance.web.form.FieldChar.include({
|
||||
is_syntax_valid: function()
|
||||
{
|
||||
if(this.options.pattern)
|
||||
{
|
||||
var val = this.$('input').val(),
|
||||
regex = new RegExp(
|
||||
this.options.pattern, this.options.pattern_modifiers || ''
|
||||
);
|
||||
if(!!val && !regex.test(this.$('input').val()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user