Disable Copy/Paste in field testbox
Means?
Please elaborate on the scenario
i have a text editor field , user can not paste any content , only write not allow for paste any data
Hey mate, you can do these through Client Script related to the doctype of that field;
frappe.ui.form.on('YOUR DOCTYPE HERE', {
refresh(frm) {
var field = frm.get_field("YOUR FIELDNAME HERE");
if (field) {
field.$input.on('paste', function(e) {
frappe.msgprint(__('Pasting is disabled in this field.'));
e.preventDefault();
});
}
}
});
However keep in mind that this will not work in “Quick Entry”.
Also note that using keyboard clipboards on mobile devices might bypass this.
3 Likes
field type is TextEditor (not working)
Hey mate, the previous code targets input fields. For text editor you need to target quill.
frappe.ui.form.on('DOCTYPE', {
refresh(frm) {
setTimeout(() => {
const editorContainer = frm.fields_dict['FIELD_NAME'].$wrapper;
const quillEditor = editorContainer.find('.ql-editor').get(0);
if (quillEditor) {
quillEditor.addEventListener('paste', (e) => {
frappe.msgprint(__('Pasting is disabled in this field.'));
e.preventDefault();
e.stopPropagation();
return false;
}, true);
}
}, 500);
}
});
Tested on v15
2 Likes
thanks
its working