Client Side JavaScript Validation
Struts Validator Framework provides an easy-to-use mechanism for performing client-side validation. It's very useful to validate some fields on the client-side before sending the data to the server for processing. By this way we can ensure that the data send to the server is valid. Performing validations on the client-side save the user a round trip time to the server.
For each validation routine defined in the validation-rules.xml file Struts provides an optional JavaScript code that can run on the client-side to perform the same validation that takes place on the server side.
Let's take a login application for our example. Our LoginForm extends DynaValidatorForm.
1.
2.
3.
4.
The following validations are defined in the validation.xml file.
01.
02.
03.
04.
05.
06.
07.
08.
09. minlength
10. 6
11.
12.
13.
To enable client-side validation you have to place the Struts HTML Tag Library's javascript tag in each jsp page for which you need to preform client-side validation.
01.
02.
03.
04.JS Validation
05.
06.
07. >
08.
09. User Name :
10. Password :
11.
12.
13.
14.
The formName property of the javascript tag hold the name of the form specified in the validation.xml file.
Next step is to specify the onsubmit attribute of the HTML Tag Library's form tag. The onsubmit attribute is used to specify the javascript code that should be executed when the form is submitted.
The name of the validate method generated by the javascipt tag is formed by concatenating "validate" with the name of the form specified in the javascript. For example, our form name is "LoginForm" so the generated method name will be "validateLoginForm". If the form name is "loginForm", the generated method name will be "validateLoginForm"
Run the application. The login.jsp page will be displayed. Click the login button without entering t
相关文档:
事实上IE已经为我们内嵌了WebBrowser控件,已经能够很好的支持我们常用的打印功能了。通过该控件的功能调用,用户可以将当前的Html页面输出到打印机上,用户只需要将要打印的数据组织成Html页面,然后调用WebBrowser的打印功能就可以很好的实现所见即所得的打印功能。不过这种打印存在的缺点就是打印精度不够,如果需要精确 ......
<input type="text" onblur="if (value ==''){value='请输入关键字'}" onfocus="if (value =='请输入关键字'){value =''}" id="q" name="q" value="请输入关键字" style="width: 100px; height: 14px;">
......
JavaScript就这么回事 (JS基础知识整理)
1 创建脚本块
1: <script language=”JavaScript”>
2: JavaScript code goes
here
3: </script>
2 隐藏脚本代码
1: <script language=”JavaScript”>
2: <!&ndas ......
Javascript中的Array对象没有Remove方法,在网上找到了一函数
function
RemoveArray(array,attachId
)
{
for
(
var
i
=
0
,n
=
0
;i
<
array.length;i
++
)
{
if
(array[i]
......
第一种:
+展开
-HTML
<html>
<head>
</head>
<body>
<form name="form1">
<input type="text" name="getinfo" value="http://www.shuwo.net" size="40"><button onclick="alert(document.form1.getinfo.value ......