Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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


Ïà¹ØÎĵµ£º

javascriptʵÏÖkey value¶ÔÏó

JavaScriptµÄʵÏÖµÄMap£¬ÓÃ×Åͦ·½±ãµÄ£¬²»ÖªµÀÐÔÄÜÔõôÑù¡£
×Ô¼ºÓÃÖ»Óв»³¬¹ý10¸öÔªËØ£¬ËùÒÔÐÔÄÜÎÞËùνÁË¡£
/********************jsmap.js**************************/
/////// map Àà
function classMap() {
  this.map = new Array();
 
  var struct = function(key,
value){
  & ......

×î½ü×Ô¼ºÔÚдjavascript/html/cssµÄÊ÷¿Ø¼þ

    Íê³ÉÒÔϲ¿·Ö£º
    1. Ê÷¿ÉÒÔ½ÓÊÜsingleXml¸ñʽºÍjsonÒÔ¼°jsonarray¸ñʽµÄÊý¾Ý£»
    2. ¸´Ñ¡¿ò¹´Ñ¡ºÍÕÛµþ×Ó½ÚµãµÄÂß¼­ÓÃdivǶÌ×À´ÊµÏÖ,ЧÂʸü¸ß;²¢ÌṩÁË¿ìËÙ»­Ê÷µÄ·½·¨;(´æÔÚbug:¿ìËÙ»­Ê÷ЧÂʲ¢²»¸ß,divǶÌ×ÓÐÎÊÌâ);
    3.Ôö¼ÓÊ÷µÄÉî¶È this.depth ......

ÓÃjavaScriptÖÆ×÷ÍøÒ³ÖÐÏÔʾÁбí

µÚÒ»ÖÖ:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ÎÞ±êÌâÎ ......

JavaScript Cookie µÄÕýÈ·Ó÷¨

function getCookies(name)
{
var arr = document.cookie.match(new RegExp(&quot;(^| )&quot;+name+&quot;=([^;]*)(;|$)&quot;));
if(arr != null) return unescape(arr[2]); return &#039;&#039;;
}
function setCookie(name, value, expires,
function getCookies(name)
{
var a ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ