将jQuery验证插件与以struts编写的表单一起使用

编程入门 行业动态 更新时间:2024-10-26 08:32:35
本文介绍了将jQuery验证插件与以struts编写的表单一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想实现jQuery验证插件,以便用Java和Struts编写的Web应用程序中使用.我只想使用它来验证表单输入,以查看它们是否符合某些规则,然后再将其提交给数据库.我正在尝试实现的项目是由其他人编写的,我没有访问权限,也无法重写它.

I want to implement the jQuery validation plugin for use in a web application written in java and struts. I just want to use it to validate form inputs to see if they conform to certain rules before it's submitted to a database. The project I'm trying to implement this in was written by someone else, I don't have access to them, and I can't rewrite it.

这是我要验证的表单输入之一:

Here is one of the form inputs that I want to validate:

<html:text property="groomFirstName" maxlength="30" tabindex="1" styleId="groomFirstName" size="15" onchange="properCase(this.id); needToConfirm=true;" />

我已经为插件编写了一些自定义方法.我已经在一个简单的HTML表单上对其进行了测试,但是我没有办法像上面的代码行那样使它们与struts代码一起使用.

I've written some custom methods for the plugin. I have tested them on a simple HTML form, but I don't how to make them work with the struts code like the line of code above.

推荐答案

使用Struts生成表单的事实是无关紧要的. JavaScript在浏览器中执行,HTML是HTML.

The fact that Struts is used to generate the form is irrelevant. JavaScript executes in the browser, and HTML is HTML.

上面的代码行不是HTML.这是一个Struts JSP标记,在服务器端进行评估,并生成发送到浏览器的HTML代码. jQuery只关心HTML.上面的代码将生成以下HTML:

The line of code above is not HTML. It's a Struts JSP tag that is evaluated at server-side and generates HTML code that is sent to the browser. jQuery only cares about the HTML. And the above code will generate the following HTML:

<input type="text" name="groomFirstName" maxlength="30" tabindex="1" id="groomFirstName" size="15" onchange="properCase(this.id); needToConfirm=true;" />

更多推荐

将jQuery验证插件与以struts编写的表单一起使用

本文发布于:2023-10-09 18:03:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476399.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   插件   jQuery   struts

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!