Applying JS validation to a field

how to apply js validation to specific field in a doctype.
I ask what’s the way to do it

https://erpnext.com/docs/user/manual/en/customize-erpnext/custom-scripts

in the same way a can use it to build a phone number format right?

sorry I’m new in the framework

1 Like

Yes. JavaScript which can be applied for the specific field.

I know js but Idk how to tie the js validation in a phone number field through the script.

It isn’t rocket science. You can find some script on Google and bind it to the input inside the div which has data-fieldname equal to the field you’re targeting. You can use jQuery as well if you’re comfortable with that.

Hello all,

Please put your answer code in replies after few days links which you have shared as answer get disabled.
Now i have problem in applying js validation for frappe, but not able to access your posted answer

Hello @snv
How to achieve this in a way that will not be affected when doing upgrade?

Regards
Bilal

What do you want to achieve?

How to add this script inside div in a way that will not be removed when updating erpnext?

This script can need to be added in which file?

Regards
Bilal

You can use the Custom Script DocType for this purpose.

Updated link: https://erpnext.com/docs/user/manual/en/customize-erpnext/custom-scripts