I have a textfield which should allow pasting only numbers in Struts 2.
I tried using onPaste
attribute in textfield but it throws below exception
org.apache.jasper.JasperException: /WEB-INF/**.jsp Attribute onPaste invalid for tag textfield according to TLD
Is there anyway to do above function without paste event?
Advertisement
Answer
Dynamic attributes not allowed in Struts 2.0. You should upgrade to the latest version. Currently 2.3.20 is available.
Struts 2.3.20 is the “best available” version of Struts in the 2.3 series.
onpaste
is a HTML attribute to dynamically bind the event handler to the element. But you can also use a jQuery code to do it manually
$("input[type=text]").on("paste", function() { return isAllowNu(); });
It will handle paste
event for all input
text elements. The texfield
s are generating these HTML tags.