How can I add an mask into an Data field?

I’m creating a new app, and there’s an field I need to create a Input Mask, what’s the better way to do it?

Hi @fellipeh:

Is doable importing via hooks.py a library like jquery-mask-plugin, and using it with jquery in a client script.

frappe.ui.form.on('your_doctype', {
	refresh(frm) {
		frappe.require("/assets/your_app/node_modules/jquery-mask-plugin/dist/jquery.mask.min.js")
		$('[data-fieldname="your_field"] input').mask('AAA 000-S0S')
	}
})

Hope this helps.

2 Likes