Javascript粘贴事件以允许Struts 2中的数字 [英] Javascript paste event to allow numbers in Struts 2

查看:61
本文介绍了Javascript粘贴事件以允许Struts 2中的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本字段,只允许在Struts2中粘贴数字. 我尝试在文本字段中使用onPaste属性,但它抛出异常

I have a textfield which should allow pasting only numbers in Struts2. 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?

推荐答案

Struts 2.0中不允许使用动态属性.您应该升级到最新版本.目前 2.3.20 可用.

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是2.3系列中Struts的最佳可用"版本.

Struts 2.3.20 is the "best available" version of Struts in the 2.3 series.

onpaste是一个HTML属性,用于将事件处理程序动态绑定到该元素.但是您也可以使用jQuery代码手动完成

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();
});

它将处理所有input文本元素的paste事件. texfield正在生成这些HTML标签.

It will handle paste event for all input text elements. The texfields are generating these HTML tags.

这篇关于Javascript粘贴事件以允许Struts 2中的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆