ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Applying JS validation to a field


#1

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


#2

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


#3

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


#4

sorry I’m new in the framework


#5

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


#6

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


#7

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.


#8

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


#9

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

Regards
Bilal


#10

What do you want to achieve?


#11

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


#12

You can use the Custom Script DocType for this purpose.

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