0
Personal greetings,
I have a generic javascript file util.js with a Function not to allow copy and paste.
$('input').bind('copy paste', function (e) {
e.preventDefault();
});
On a specific page, I need a certain field to allow me to copy and paste and I didn’t want to get rid of the util.js that doesn’t allow it on the other pages of the application. Is there any way to allow pasting? Or turn off this validation for the specific page?
Thank you
Edit1: I called the unbind(); direct method on the page that way and it worked
$(document).ready(function() {
$("input").unbind();
However, it works for all screen inputs. I tried to pass the id/field name as parameter but it didn’t work. Ideally, only one field allows copying and pasting.
Thanks in advance
Edit2:
The field you need to allow copy and paste is this:
<td width="306" align="center">
<s:textfield id="idDesc%{#rowStatus.index}" cssClass="bg_input txtTable" cssStyle="%{listDespRec[#rowStatus.index].listError[2].aplicarCss}" name="listDespRec[%{#rowStatus.index}].observacaoLancamento" value="%{listDespRec[#rowStatus.index].observacaoLancamento}" size="35" maxlength="30"/>
</td>
Any suggestions on how to pass this field in the unbind?
That way here it’s not working
$(document).ready(function() {
$('#listDespRec[%{#rowStatus.index}].observacaoLancamento').unbind('copy paste');
If you put the above code on the page you want to copy and paste without preventDefault, it doesn’t work?
– LeAndrade
Opa @Leandrade, thanks for answering. It does not work, I believe that the first validation prevails over the page validation
– Yuri Iagi
Yes, this is because the validator system has not been removed. You could share the useful.js also to facilitate the response ?
– codermarcos
Opa @Marcosjunior, thank you for the reply. The util.js file contains only this copy and paste validation that is called on the startup of all pages. As I edited in the question, passing the unbind(); right on the page I need to change, it allows copying and pasting. The question now is the field, as all inputs are disabling bind('copy Paste'). Passing the id/field name, it didn’t work. The ideal would be to disable only for the field
– Yuri Iagi