I am trying to validate a phone field using a custom python library that checks if a given phone number is valid or not. If it is invalid I would like to show the field in red, somewhat like how we see mandatory fields highlighted after we click submit without filling them in. How do I trigger this highlighting of the field?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
Hi Ragav,
if your main goal is to validate field before saving record and raise validation error then you cam put your login into @api.constrains to achieve this.
When user click on save button then @api.constrains will execute and if number not on correct format then raise error.
But if you really want to make field as red like mandatory then you need to do the JS stuff to validate number and and make field border red using JS calculation.
There is an already module to validate number:
https://stackoverflow.com/questions/16135069/python-validation-mobile-number
https://apps.odoo.com/apps/modules/10.0/inputmask_widget/
Using JD:
https://stackoverflow.com/questions/26211225/validating-phone-numbers-using-javascript
Regards
Haresh Kansara
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
2
ม.ค. 21
|
3676 | ||
Form view fields validation
แก้ไขแล้ว
|
|
1
พ.ย. 23
|
2710 | |
statusbar does not highlight. [Closed]
แก้ไขแล้ว
|
|
4
ส.ค. 15
|
7247 | |
|
0
มี.ค. 15
|
4178 | ||
|
3
มี.ค. 15
|
4580 |