简体   繁体   中英

Odoo 8 - add event handler on input text in javascript

is there a way to add an event handler which handles an onchange event on input text. I need to put constraint on the invoice line where the user shouldn't fill a quantity greater than the value in the text box.

<field name="quantity" event="onchange(this)"/>

onchange(){
console.log..
}

10x

For your task you don't need to use js, use python code for this, you can use @api.onchange and throw warnings or you can also create db constrains from there. db constrains works only when saving while @api.onchange works during editing

And if you still want to use js and cause headaches you can use jQuery to set onchange on any fields like this

$(SELECTOR).change(function (e) {});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM