- 浏览: 845767 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (379)
- struts (5)
- hibernate (16)
- spring (16)
- ssh (20)
- MySQL (16)
- 数据库脚本 (2)
- DownLoad (1)
- GAE (5)
- Java (103)
- LoadRunner (2)
- VF (1)
- 学习资料 (24)
- 软件使用 (21)
- 通信类 (4)
- 生活 (3)
- J2ME (1)
- 心理学 (1)
- Linux (26)
- Android (3)
- Oracle (1)
- 面向对象概念&面试准备 (11)
- ExtJs (2)
- Google Map (1)
- Flex (47)
- 算法研究 (1)
- share (20)
- python (1)
- MongoDB (7)
- centos6 (13)
- C++ (8)
- DB2 (3)
- C# (1)
- 代码片段 (24)
- Lucene (2)
- php (1)
- NodeJS (1)
- Express (1)
最新评论
-
shua1991:
已阅,我表示同意。
Eclipse统计代码行数 -
nakedou:
写的不错,挺详细的
在CentOS中使用 yum 安装MongoDB及服务器端配置 -
sjp524617477:
好方法
Eclipse统计代码行数 -
simpletrc:
<script>ale ...
Java写到.txt文件,如何实现换行 -
csdn_zuoqiang:
Apache Ftp Server,目前是1.0.4,非常好的 ...
Apache FtpServer在64位系统下服务不能启动解决方法
第二十五部分:在同个目录下,添加 validator-rules.xml ,这个在 struts 开发包中有,只需要 copy 过来就
可以用了。为了方便大家,我这里将里面配置代码粘贴出来:
<? xml version="1.0" encoding="ISO-8859-1" ?> <! DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN" "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd" > <!-- This file contains the default Struts Validator pluggable validator definitions. It should be placed somewhere under /WEB-INF and referenced in the struts-config.xml under the plug-in element for the ValidatorPlugIn. <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml"/> </plug-in> These are the default error messages associated with each validator defined in this file. They should be added to your projects ApplicationResources.properties file or you can associate new ones by modifying the pluggable validators msg attributes in this file. # Struts Validator Error Messages errors.required={0} is required. errors.minlength={0} can not be less than {1} characters. errors.maxlength={0} can not be greater than {1} characters. errors.invalid={0} is invalid. errors.byte={0} must be a byte. errors.short={0} must be a short. errors.integer={0} must be an integer. errors.long={0} must be a long. errors.float={0} must be a float. errors.double={0} must be a double. errors.date={0} is not a date. errors.range={0} is not in the range {1} through {2}. errors.creditcard={0} is an invalid credit card number. errors.email={0} is an invalid e-mail address. --> < form-validation > < global > < validator name ="required" classname ="org.apache.struts.validator.FieldChecks" method ="validateRequired" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" msg ="errors.required" > < javascript > <![CDATA[ function validateRequired(form) { var isValid = true; var focusField = null; var i = 0; var fields = new Array(); oRequired = new required(); for (x in oRequired) { var field = form[oRequired[x][0]]; if (field.type == 'text' || field.type == 'textarea' || field.type == 'file' || field.type == 'select-one' || field.type == 'radio' || field.type == 'password' || field.type == 'hidden') { var value = ''; // get field's value if (field.type == "select-one") { var si = field.selectedIndex; if (si >= 0) { value = field.options[si].value; } } else { value = field.value; } if (trim(value).length == 0) { if (i == 0) { focusField = field; } fields[i++] = oRequired[x][1]; isValid = false; } } } if (fields.length > 0) { if(focusField.type!='hidden'){ focusField.focus(); } alert(fields.join('\n')); } return isValid; } // Trim whitespace from left and right sides of s. function trim(s) { return s.replace( /^\s*/, "" ).replace( /\s*$/, "" ); } ]]> </ javascript > </ validator > <!-- Åжϸ´Ñ¡¿ò²»ÄÜΪ¿Õ ÕÔÆ·º£ 2004 --> < validator name ="requiredif" classname ="org.apache.struts.validator.FieldChecks" method ="validateRequiredIf" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest" msg ="errors.required" > < javascript > <![CDATA[ function validateRequiredIf(form) { var isValid = true; var focusField = null; var i = 0; var fields = new Array(); var j=0; oRequiredif = new requiredif(); for (x in oRequiredif) { var field = form[oRequiredif[x][0]]; for(var ii=0;ii<field.length;ii++){ if(field[ii].checked==true){ j++; } } if (j == 0) { if (i == 0) { focusField = field; } fields[i++] = oRequiredif[x][1]; isValid = false; } } if (fields.length > 0) { alert(fields.join('\n')); } return isValid; } ]]> </ javascript > </ validator > < validator name ="minlength" classname ="org.apache.struts.validator.FieldChecks" method ="validateMinLength" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.minlength" > < javascript > <![CDATA[ function validateMinLength(form) { var isValid = true; var focusField = null; var i = 0; var fields = new Array(); oMinLength = new minlength(); for (x in oMinLength) { var field = form[oMinLength[x][0]]; if (field.type == 'text' || field.type == 'textarea'|| field.type == 'password') { var iMin = parseInt(oMinLength[x][2]("minlength")); if ((trim(field.value).length > 0) && (field.value.length < iMin)) { if (i == 0) { focusField = field; } fields[i++] = oMinLength[x][1]; isValid = false; } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return isValid; } ]]> </ javascript > </ validator > < validator name ="maxlength" classname ="org.apache.struts.validator.FieldChecks" method ="validateMaxLength" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.maxlength" > < javascript > <![CDATA[ function validateMaxLength(form) { var isValid = true; var focusField = null; var i = 0; var fields = new Array(); oMaxLength = new maxlength(); for (x in oMaxLength) { var field = form[oMaxLength[x][0]]; if (field.type == 'text' || field.type == 'textarea'|| field.type == 'password') { var iMax = parseInt(oMaxLength[x][2]("maxlength")); if (field.value.length > iMax) { if (i == 0) { focusField = field; } fields[i++] = oMaxLength[x][1]; isValid = false; } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return isValid; } ]]> </ javascript > </ validator > < validator name ="mask" classname ="org.apache.struts.validator.FieldChecks" method ="validateMask" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.invalid" > < javascript > <![CDATA[ function validateMask(form) { var isValid = true; var focusField = null; var i = 0; var fields = new Array(); oMasked = new mask(); for (x in oMasked) { var field = form[oMasked[x][0]]; if ((field.type == 'text' || field.type == 'textarea'|| field.type == 'password') && (field.value.length > 0)) { if (!matchPattern(field.value, oMasked[x][2]("mask"))) { if (i == 0) { focusField = field; } fields[i++] = oMasked[x][1]; isValid = false; } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return isValid; } function matchPattern(value, mask) { return mask.exec(value); } ]]> </ javascript > </ validator > < validator name ="byte" classname ="org.apache.struts.validator.FieldChecks" method ="validateByte" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.byte" jsFunctionName ="ByteValidations" > < javascript > <![CDATA[ function validateByte(form) { var bValid = true; var focusField = null; var i = 0; var fields = new Array(); oByte = new ByteValidations(); for (x in oByte) { var field = form[oByte[x][0]]; if (field.type == 'text' || field.type == 'textarea' || field.type == 'select-one' || field.type == 'radio') { var value = ''; // get field's value if (field.type == "select-one") { var si = field.selectedIndex; if (si >= 0) { value = field.options[si].value; } } else { value = field.value; } if (value.length > 0) { if (!isAllDigits(value)) { bValid = false; if (i == 0) { focusField = field; } fields[i++] = oByte[x][1]; } else { var iValue = parseInt(value); if (isNaN(iValue) || !(iValue >= -128 && iValue <= 127)) { if (i == 0) { focusField = field; } fields[i++] = oByte[x][1]; bValid = false; } } } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return bValid; } ]]> </ javascript > </ validator > < validator name ="short" classname ="org.apache.struts.validator.FieldChecks" method ="validateShort" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.short" jsFunctionName ="ShortValidations" > < javascript > <![CDATA[ function validateShort(form) { var bValid = true; var focusField = null; var i = 0; var fields = new Array(); oShort = new ShortValidations(); for (x in oShort) { var field = form[oShort[x][0]]; if (field.type == 'text' || field.type == 'textarea' || field.type == 'select-one' || field.type == 'radio') { var value = ''; // get field's value if (field.type == "select-one") { var si = field.selectedIndex; if (si >= 0) { value = field.options[si].value; } } else { value = field.value; } if (value.length > 0) { if (!isAllDigits(value)) { bValid = false; if (i == 0) { focusField = field; } fields[i++] = oShort[x][1]; } else { var iValue = parseInt(value); if (isNaN(iValue) || !(iValue >= -32768 && iValue <= 32767)) { if (i == 0) { focusField = field; } fields[i++] = oShort[x][1]; bValid = false; } } } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return bValid; } ]]> </ javascript > </ validator > < validator name ="integer" classname ="org.apache.struts.validator.FieldChecks" method ="validateInteger" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.integer" jsFunctionName ="IntegerValidations" > < javascript > <![CDATA[ function validateInteger(form) { var bValid = true; var focusField = null; var i = 0; var fields = new Array(); oInteger = new IntegerValidations(); for (x in oInteger) { var field = form[oInteger[x][0]]; if (field.type == 'text' || field.type == 'textarea' || field.type == 'select-one' || field.type == 'radio') { var value = ''; // get field's value if (field.type == "select-one") { var si = field.selectedIndex; if (si >= 0) { value = field.options[si].value; } } else { value = field.value; } if (value.length > 0) { if (!isAllDigits(value)) { bValid = false; if (i == 0) { focusField = field; } fields[i++] = oInteger[x][1]; } else { var iValue = parseInt(value); if (isNaN(iValue) || !(iValue >= -2147483648 && iValue <= 2147483647)) { if (i == 0) { focusField = field; } fields[i++] = oInteger[x][1]; bValid = false; } } } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return bValid; } function isAllDigits(argvalue) { argvalue = argvalue.toString(); var validChars = "0123456789"; var startFrom = 0; if (argvalue.substring(0, 2) == "0x") { validChars = "0123456789abcdefABCDEF"; startFrom = 2; } else if (argvalue.charAt(0) == "-") { startFrom = 1; } for (var n = startFrom; n < argvalue.length; n++) { if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false; } return true; } ]]> </ javascript > </ validator > < validator name ="long" classname ="org.apache.struts.validator.FieldChecks" method ="validateLong" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.long" /> < validator name ="float" classname ="org.apache.struts.validator.FieldChecks" method ="validateFloat" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.float" jsFunctionName ="FloatValidations" > < javascript > <![CDATA[ function validateFloat(form) { var bValid = true; var focusField = null; var i = 0; var fields = new Array(); oFloat = new FloatValidations(); for (x in oFloat) { var field = form[oFloat[x][0]]; if (field.type == 'text' || field.type == 'textarea' || field.type == 'select-one' || field.type == 'radio') { var value = ''; // get field's value if (field.type == "select-one") { var si = field.selectedIndex; if (si >= 0) { value = field.options[si].value; } } else { value = field.value; } if (value.length > 0) { // remove '.' before checking digits var tempArray = value.split('.'); var joinedString= tempArray.join(''); if (!isAllDigits(joinedString)) { bValid = false; if (i == 0) { focusField = field; } fields[i++] = oFloat[x][1]; } else { var iValue = parseFloat(value); if (isNaN(iValue)) { if (i == 0) { focusField = field; } fields[i++] = oFloat[x][1]; bValid = false; } } } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return bValid; } ]]> </ javascript > </ validator > < validator name ="double" classname ="org.apache.struts.validator.FieldChecks" method ="validateDouble" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.double" /> < validator name ="date" classname ="org.apache.struts.validator.FieldChecks" method ="validateDate" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.date" jsFunctionName ="DateValidations" > < javascript > <![CDATA[ function validateDate(form) { var bValid = true; var focusField = null; var i = 0; var fields = new Array(); oDate = new DateValidations(); for (x in oDate) { var value = form[oDate[x][0]].value; var datePattern = oDate[x][2]("datePatternStrict"); if ((form[oDate[x][0]].type == 'text' || form[oDate[x][0]].type == 'textarea') && (value.length > 0) && (datePattern.length > 0)) { var MONTH = "MM"; var DAY = "dd"; var YEAR = "yyyy"; var orderMonth = datePattern.indexOf(MONTH); var orderDay = datePattern.indexOf(DAY); var orderYear = datePattern.indexOf(YEAR); if ((orderDay < orderYear && orderDay > orderMonth)) { var iDelim1 = orderMonth + MONTH.length; var iDelim2 = orderDay + DAY.length; var delim1 = datePattern.substring(iDelim1, iDelim1 + 1); var delim2 = datePattern.substring(iDelim2, iDelim2 + 1); if (iDelim1 == orderDay && iDelim2 == orderYear) { dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$"); } else if (iDelim1 == orderDay) { dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$"); } else if (iDelim2 == orderYear) { dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$"); } else { dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$"); } var matched = dateRegexp.exec(value); if(matched != null) { if (!isValidDate(matched[2], matched[1], matched[3])) { if (i == 0) { focusField = form[oDate[x][0]]; } fields[i++] = oDate[x][1]; bValid = false; } } else { if (i == 0) { focusField = form[oDate[x][0]]; } fields[i++] = oDate[x][1]; bValid = false; } } else if ((orderMonth < orderYear && orderMonth > orderDay)) { var iDelim1 = orderDay + DAY.length; var iDelim2 = orderMonth + MONTH.length; var delim1 = datePattern.substring(iDelim1, iDelim1 + 1); var delim2 = datePattern.substring(iDelim2, iDelim2 + 1); if (iDelim1 == orderMonth && iDelim2 == orderYear) { dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$"); } else if (iDelim1 == orderMonth) { dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$"); } else if (iDelim2 == orderYear) { dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$"); } else { dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$"); } var matched = dateRegexp.exec(value); if(matched != null) { if (!isValidDate(matched[1], matched[2], matched[3])) { if (i == 0) { focusField = form[oDate[x][0]]; } fields[i++] = oDate[x][1]; bValid = false; } } else { if (i == 0) { focusField = form[oDate[x][0]]; } fields[i++] = oDate[x][1]; bValid = false; } } else if ((orderMonth > orderYear && orderMonth < orderDay)) { var iDelim1 = orderYear + YEAR.length; var iDelim2 = orderMonth + MONTH.length; var delim1 = datePattern.substring(iDelim1, iDelim1 + 1); var delim2 = datePattern.substring(iDelim2, iDelim2 + 1); if (iDelim1 == orderMonth && iDelim2 == orderDay) { dateRegexp = new RegExp("^(\\d{4})(\\d{2})(\\d{2})$"); } else if (iDelim1 == orderMonth) { dateRegexp = new RegExp("^(\\d{4})(\\d{2})[" + delim2 + "](\\d{2})$"); } else if (iDelim2 == orderDay) { dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})(\\d{2})$"); } else { dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{2})$"); } var matched = dateRegexp.exec(value); if(matched != null) { if (!isValidDate(matched[3], matched[2], matched[1])) { if (i == 0) { focusField = form[oDate[x][0]]; } fields[i++] = oDate[x][1]; bValid = false; } } else { if (i == 0) { focusField = form[oDate[x][0]]; } fields[i++] = oDate[x][1]; bValid = false; } } else { if (i == 0) { focusField = form[oDate[x][0]]; } fields[i++] = oDate[x][1]; bValid = false; } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return bValid; } function isValidDate(day, month, year) { if (month < 1 || month > 12) { return false; } if (day < 1 || day > 31) { return false; } if ((month == 4 || month == 6 || month == 9 || month == 11) && (day == 31)) { return false; } if (month == 2) { var leap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day>29 || (day == 29 && !leap)) { return false; } } return true; } ]]> </ javascript > </ validator > <!-- range is deprecated use intRange instead --> < validator name ="range" classname ="org.apache.struts.validator.FieldChecks" method ="validateIntRange" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="integer" msg ="errors.range" > < javascript > <![CDATA[ function validateRange(form) { return validateIntRange(form); } ]]> </ javascript > </ validator > < validator name ="intRange" classname ="org.apache.struts.validator.FieldChecks" method ="validateIntRange" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="integer" msg ="errors.range" > < javascript > <![CDATA[ function validateIntRange(form) { var isValid = true; var focusField = null; var i = 0; var fields = new Array(); oRange = new intRange(); for (x in oRange) { var field = form[oRange[x][0]]; if ((field.type == 'text' || field.type == 'textarea') && (field.value.length > 0)) { var iMin = parseInt(oRange[x][2]("min")); var iMax = parseInt(oRange[x][2]("max")); var iValue = parseInt(field.value); if (!(iValue >= iMin && iValue <= iMax)) { if (i == 0) { focusField = field; } fields[i++] = oRange[x][1]; isValid = false; } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return isValid; } ]]> </ javascript > </ validator > < validator name ="floatRange" classname ="org.apache.struts.validator.FieldChecks" method ="validateFloatRange" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="float" msg ="errors.range" > < javascript > <![CDATA[ function validateFloatRange(form) { var isValid = true; var focusField = null; var i = 0; var fields = new Array(); oRange = new floatRange(); for (x in oRange) { var field = form[oRange[x][0]]; if ((field.type == 'text' || field.type == 'textarea') && (field.value.length > 0)) { var fMin = parseFloat(oRange[x][2]("min")); var fMax = parseFloat(oRange[x][2]("max")); var fValue = parseFloat(field.value); if (!(fValue >= fMin && fValue <= fMax)) { if (i == 0) { focusField = field; } fields[i++] = oRange[x][1]; isValid = false; } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return isValid; } ]]> </ javascript > </ validator > < validator name ="creditCard" classname ="org.apache.struts.validator.FieldChecks" method ="validateCreditCard" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.creditcard" > < javascript > <![CDATA[ function validateCreditCard(form) { var bValid = true; var focusField = null; var i = 0; var fields = new Array(); oCreditCard = new creditCard(); for (x in oCreditCard) { if ((form[oCreditCard[x][0]].type == 'text' || form[oCreditCard[x][0]].type == 'textarea') && (form[oCreditCard[x][0]].value.length > 0)) { if (!luhnCheck(form[oCreditCard[x][0]].value)) { if (i == 0) { focusField = form[oCreditCard[x][0]]; } fields[i++] = oCreditCard[x][1]; bValid = false; } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return bValid; } /** * Reference: http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl */ function luhnCheck(cardNumber) { if (isLuhnNum(cardNumber)) { var no_digit = cardNumber.length; var oddoeven = no_digit & 1; var sum = 0; for (var count = 0; count < no_digit; count++) { var digit = parseInt(cardNumber.charAt(count)); if (!((count & 1) ^ oddoeven)) { digit *= 2; if (digit > 9) digit -= 9; }; sum += digit; }; if (sum == 0) return false; if (sum % 10 == 0) return true; }; return false; } function isLuhnNum(argvalue) { argvalue = argvalue.toString(); if (argvalue.length == 0) { return false; } for (var n = 0; n < argvalue.length; n++) { if ((argvalue.substring(n, n+1) < "0") || (argvalue.substring(n,n+1) > "9")) { return false; } } return true; } ]]> </ javascript > </ validator > < validator name ="email" classname ="org.apache.struts.validator.FieldChecks" method ="validateEmail" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.email" > < javascript > <![CDATA[ function validateEmail(form) { var bValid = true; var focusField = null; var i = 0; var fields = new Array(); oEmail = new email(); for (x in oEmail) { if ((form[oEmail[x][0]].type == 'text' || form[oEmail[x][0]].type == 'textarea') && (form[oEmail[x][0]].value.length > 0)) { if (!checkEmail(form[oEmail[x][0]].value)) { if (i == 0) { focusField = form[oEmail[x][0]]; } fields[i++] = oEmail[x][1]; bValid = false; } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return bValid; } /** * Reference: Sandeep V. Tamhankar (stamhankar@hotmail.com), * http://javascript.internet.com */ function checkEmail(emailStr) { if (emailStr.length == 0) { return true; } var emailPat=/^(.+)@(.+)$/; var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"; var validChars="\[^\\s" + specialChars + "\]"; var quotedUser="(\"[^\"]*\")"; var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/; var atom=validChars + '+'; var word="(" + atom + "|" + quotedUser + ")"; var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$"); var matchArray=emailStr.match(emailPat); if (matchArray == null) { return false; } var user=matchArray[1]; var domain=matchArray[2]; if (user.match(userPat) == null) { return false; } var IPArray = domain.match(ipDomainPat); if (IPArray != null) { for (var i = 1; i <= 4; i++) { if (IPArray[i] > 255) { return false; } } return true; } var domainArray=domain.match(domainPat); if (domainArray == null) { return false; } var atomPat=new RegExp(atom,"g"); var domArr=domain.match(atomPat); var len=domArr.length; if ((domArr[domArr.length-1].length < 2) || (domArr[domArr.length-1].length > 3)) { return false; } if (len < 2) { return false; } return true; } ]]> </ javascript > </ validator > <!-- ÅжÏÊý×éÿ¸öÊýÖµ¶¼²»ÄÜΪ¿Õ ÕÔÆ·º£ 2004 --> < validator name ="requiredArray" classname ="org.apache.struts.validator.FieldChecks" method ="validateRequiredArray" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.required" jsFunctionName ="RequiredArrayValidations" > < javascript > <![CDATA[ function validateRequiredArray(form) { var isValid = true; var focusField = null; var i = 0; var fields = new Array(); var j=0; oRequired = new RequiredArrayValidations(); for (x in oRequired) { var field = form[oRequired[x][0]]; for(var ii=0;ii<field.length;ii++){ if(field[ii].value.length>0){ j++; } } if (j < field.length) { if (i == 0) { focusField = field; } fields[i++] = oRequired[x][1]; isValid = false; } } if (fields.length > 0) { alert(fields.join('\n')); } return isValid; } ]]> </ javascript > </ validator > <!-- ÅжÏÊý×éÿ¸ö²»Îª¿ÕµÄÊýÖµ¶¼±ØÐëΪÕûÐÍ ÕÔÆ·º£ 2004 --> < validator name ="integerArray" classname ="org.apache.struts.validator.FieldChecks" method ="validateIntegerArray" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.integer" jsFunctionName ="IntegerArrayValidations" > < javascript > <![CDATA[ function validateIntegerArray(form) { var bValid = true; var focusField = null; var i = 0; var j=0; var fields = new Array(); oInteger = new IntegerArrayValidations(); for (x in oInteger) { var field = form[oInteger[x][0]]; for(var ii=0;ii<field.length;ii++){ var value=field[ii].value; if (value.length > 0) { if (!isAllDigits(value)) { bValid = false; j++; if(j==1){ focusField = field[ii]; } } else { var iValue = parseInt(value); if (isNaN(iValue) || !(iValue >= -2147483648 && iValue <= 2147483647)) { bValid = false; j++; if(j==1){ focusField = field[ii]; } } } } } if (j > 0) { fields[i++] = oInteger[x][1]; isValid = false; } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return bValid; } ]]> </ javascript > </ validator > <!-- ÅжÏÊý×éÿ¸ö²»Îª¿ÕµÄÊýÖµ¶¼±ØÐëΪ¸¡µãÐÍ ÕÔÆ·º£ 2004 --> < validator name ="floatArray" classname ="org.apache.struts.validator.FieldChecks" method ="validateFloatArray" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.float" jsFunctionName ="FloatArrayValidations" > < javascript > <![CDATA[ function validateFloatArray(form) { var bValid = true; var focusField = null; var i = 0; var j=0; var fields = new Array(); oFloat = new FloatArrayValidations(); for (x in oFloat) { var field = form[oFloat[x][0]]; for(var ii=0;ii<field.length;ii++){ var value=field[ii].value; if (value.length > 0) { // remove '.' before checking digits var tempArray = value.split('.'); var joinedString= tempArray.join(''); if (!isAllDigits(joinedString)) { bValid = false; j++; if (j == 1) { focusField = field[ii]; } } else { var iValue = parseFloat(value); if (isNaN(iValue)) { j++; if (j == 1) { focusField = field[ii]; } bValid = false; } } } } if (j > 0) { fields[i++] = oFloat[x][1]; isValid = false; } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return bValid; } ]]> </ javascript > </ validator > <!-- ÅжÏÊý×éÿ¸ö²»Îª¿ÕµÄÊýÖµ¶¼±ØÐëΪ˫¾«¶ÈÐÍ ÕÔÆ·º£ 2004 --> < validator name ="doubleArray" classname ="org.apache.struts.validator.FieldChecks" method ="validateDoubleArray" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.double" /> <!-- ÅжÏÊý×éÿ¸ö²»Îª¿ÕµÄÊýÖµ¶¼±ØÐëΪÈÕÆÚÐÍ ÕÔÆ·º£ 2004 --> < validator name ="dateArray" classname ="org.apache.struts.validator.FieldChecks" method ="validateDateArray" methodParams ="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends ="" msg ="errors.date" jsFunctionName ="DateArrayValidations" > < javascript > <![CDATA[ function validateDateArray(form) { var bValid = true; var focusField = null; var i = 0; var j=0; var fields = new Array(); oDate = new DateArrayValidations(); for (x in oDate) { var field = form[oDate[x][0]]; for(var ii=0;ii<field.length;ii++){ var value=field[ii].value; var datePattern = oDate[x][2]("datePatternStrict"); if ((value.length > 0) && (datePattern.length > 0)) { var MONTH = "MM"; var DAY = "dd"; var YEAR = "yyyy"; var orderMonth = datePattern.indexOf(MONTH); var orderDay = datePattern.indexOf(DAY); var orderYear = datePattern.indexOf(YEAR); if ((orderDay < orderYear && orderDay > orderMonth)) { var iDelim1 = orderMonth + MONTH.length; var iDelim2 = orderDay + DAY.length; var delim1 = datePattern.substring(iDelim1, iDelim1 + 1); var delim2 = datePattern.substring(iDelim2, iDelim2 + 1); if (iDelim1 == orderDay && iDelim2 == orderYear) { dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$"); } else if (iDelim1 == orderDay) { dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$"); } else if (iDelim2 == orderYear) { dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$"); } else { dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$"); } var matched = dateRegexp.exec(value); if(matched != null) { if (!isValidDate(matched[2], matched[1], matched[3])) { bValid = false; j++; } } else { bValid = false; j++; } } else if ((orderMonth < orderYear && orderMonth > orderDay)) { var iDelim1 = orderDay + DAY.length; var iDelim2 = orderMonth + MONTH.length; var delim1 = datePattern.substring(iDelim1, iDelim1 + 1); var delim2 = datePattern.substring(iDelim2, iDelim2 + 1); if (iDelim1 == orderMonth && iDelim2 == orderYear) { dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$"); } else if (iDelim1 == orderMonth) { dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$"); } else if (iDelim2 == orderYear) { dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$"); } else { dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$"); } var matched = dateRegexp.exec(value); if(matched != null) { if (!isValidDate(matched[1], matched[2], matched[3])) { j++; bValid = false; } } else { j++; bValid = false; } } else if ((orderMonth > orderYear && orderMonth < orderDay)) { var iDelim1 = orderYear + YEAR.length; var iDelim2 = orderMonth + MONTH.length; var delim1 = datePattern.substring(iDelim1, iDelim1 + 1); var delim2 = datePattern.substring(iDelim2, iDelim2 + 1); if (iDelim1 == orderMonth && iDelim2 == orderDay) { dateRegexp = new RegExp("^(\\d{4})(\\d{2})(\\d{2})$"); } else if (iDelim1 == orderMonth) { dateRegexp = new RegExp("^(\\d{4})(\\d{2})[" + delim2 + "](\\d{2})$"); } else if (iDelim2 == orderDay) { dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})(\\d{2})$"); } else { dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{2})$"); } var matched = dateRegexp.exec(value); if(matched != null) { if (!isValidDate(matched[3], matched[2], matched[1])) { j++; bValid = false; } } else { j++; bValid = false; } } else { j++; bValid = false; } } } if (j > 0) { fields[i++] = oDate[x][1]; isValid = false; } } if (fields.length > 0) { alert(fields.join('\n')); } return bValid; } ]]> </ javascript > </ validator > </ global > </ form-validation >
发表评论
-
谈谈你对MVC和三层架构的理解?
2010-12-05 12:57 1177V 是皮肉,是看到的东西 M 是骨骼,是里面真实的东西 ... -
java.lang.ClassCastException:org.apache.catalina.util.DefaultAnnotationProcessor
2010-09-01 09:03 1686org.apache.jasper.JasperExcep ... -
DAO层公共类Spring+Hibernate实现
2010-08-05 11:02 1239原文链接 http://www.blogjava.net/r ... -
假期学习清单
2010-08-03 11:08 945Struts 2.1.8 01介绍struts2及strut ... -
Struts 2.1.x + Spring 2.5.x + Hibernate 3.3.x整合需要的JAR包
2010-07-24 21:11 1740jar包名称 所在位置 说明 ... -
SSH文件-方法命名规则
2010-06-03 15:29 1762举例:表TB_Organputscale mo ... -
struts+spring+hibernate的web应用【13】
2010-05-24 00:20 878product_success.jsp页面代码: < ... -
struts+spring+hibernate的web应用【11】
2010-05-24 00:17 941products.jsp页面代码: <%@pag ... -
struts+spring+hibernate的web应用【10】
2010-05-24 00:13 905第二十六部分:接着就是写资源文件了。 ... -
struts+spring+hibernate的web应用【9】
2010-05-23 23:45 843第二十四部分: 这是一个简单的 log4j 配置方法,只是在后 ... -
struts+spring+hibernate的web应用【8】
2010-05-23 23:42 927第二十一部分:接着编写 web.xml ,代码如下: ... -
struts+spring+hibernate的web应用【7】
2010-05-23 19:34 1017第十九部分:接着编写配置文件。在 struts-config ... -
struts+spring+hibernate的web应用【6】
2010-05-23 19:30 924第十七部分:Web 层代码量比较大,涉及的地方也比较多,考虑到 ... -
struts+spring+hibernate的web应用【5】
2010-05-23 19:28 822第十五部分:这个分页方法比较简单,而且功能也齐全,许多页面级的 ... -
struts+spring+hibernate的web应用【4】
2010-05-23 19:24 922第十三部分:基本的业务层代码就这些了。因为还有分页的业务,所以 ... -
struts+spring+hibernate的web应用【3】
2010-05-23 19:22 955第十一部分:现在开始编写 Service 层代码: ... -
struts+spring+hibernate的web应用【2】
2010-05-23 19:20 1123第九部分:在com.game.products.dao.hib ... -
struts+spring+hibernate的web应用【1】
2010-05-23 19:09 1173第一步数据库部分(MySQL): DROP DATAB ... -
SSH的配置文件【部分】
2010-05-20 14:43 960---------spring 中配置hibernateTem ...
相关推荐
Python 查看主机IP及mac地址
全球各国信息化发展指数(IDI指数)是一个衡量国家和地区信息与通信技术发展水平的综合评价指标,由国际电信联盟定期发布。该指数通过三个分指数来评估:ICT接入分指数、ICT使用分指数和ICT技能分指数。ICT接入分指数涵盖了固定电话普及率、移动电话普及率、人均国际出口带宽、电脑家庭普及率和互联网家庭普及率等指标;ICT使用分指数则包括网民普及率、固定宽带人口普及率和移动宽带人口普及率;ICT技能分指数则关注平均受教育年限、中等教育毛入学率和高等教育毛入学率。这些指标共同描绘了一个国家在信息化基础设施、信息化使用、知识水平等方面的发展情况。数据覆盖了2007至2017年的区间,但需要注意的是,2009年的数据在报告中是缺失的。IDI指数为全球、区域、国家或地区信息化发展程度提供了一个综合评价手段,对于研究和比较不同国家和地区的信息化发展水平具有重要意义。
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
生产现场工艺文件执行检查管理流程说明.docx
全国各省人口密度数据2000-2021年的社科数据内容涵盖了中国31个省、直辖市、自治区的人口分布情况。这些数据通过计算年末常住总人口与地区土地面积的比值来得出人口密度,即单位土地面积上的人口数量,通常以人/平方千米为单位。数据集包含了地区、年份、年末常住总人口(万人)、面积(平方千米)以及计算得出的人口密度(人/平方千米)等关键指标。这些数据不仅反映了人口分布的地理特征,还揭示了人口增长与土地利用之间的关系,对于城市规划、资源管理、环境政策制定等领域具有重要的参考价值。通过分析这些数据,研究者可以深入了解人口变化趋势,评估不同地区的人口承载能力,并为相关政策提供数据支持。
基于PCIe接口的深度学习项目实例的详细介绍3
本数据集提供了2013至2022年间全国328个地级市的空气质量指数(AQI)和PM2.5等大气污染日度数据。数据涵盖了AQI、PM2.5、PM10、CO、SO2、NO2、O3等关键指标,为研究空气质量变化和污染趋势提供了丰富的信息。这些数据不仅包括了空气质量的定量描述,还涉及了空气污染对健康的影响,是评估空气质量的重要工具。数据来源权威,更新至2022年,为科研、政策制定和公众了解提供了宝贵的参考。
全国计算机等级考试(National Computer Rank Examination,简称NCRE),是经原国家教育委员会(现教育部)批准,由教育部教育考试院(原教育部考试中心)主办,面向社会,用于考查应试人员计算机应用知识与技能的全国性计算机水平考试体系。NCRE开考之后,受到社会广泛关注和认可,为我国信息化技术人才的培养做出了重要贡献。 三级:工程师预备级。三级证书考核面向应用、面向职业的岗位专业技能。 报名条件:报名者不受年龄、职业、学历等限制,均可根据自己学习情况和实际能力选考相应的级别和科目。考生可按照省级承办机构公布的流程在网上进行报名。 报名时间:每次考试具体报名时间由各省级承办机构规定,可登录各省级承办机构网站查询。 考试时间:NCRE在全国范围内每年举办两次考试,考试时间一般安排在3月最后一个周六至下周周一、9月倒数第二个周六至下周周一。 考试形式:统一命题,统一考试,考试形式为上机考试。 成绩:NCRE考试实行百分制计分,以等第形式公布成绩。成绩等第分为“优秀”、“良好”、“及格”、“不及格”四等。100-90分为“优秀”,89-80分为
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
使用VS-studio打开,需要安装Esayx库
CSDNApp_238.apk
免费软件, Postman + Swagger + Mock + JMeter API 文档 API 调试
【Unity3D插件】Unity3D HDRP Outline高亮发光轮廓描边插件教程
本文档主要讲述的是sqlserver内存释放;希望本文档会给有需要的朋友带来帮助;感兴趣的朋友可以过来看看
全球干旱数据集【标准化降水蒸发指数SPEI-03】(1901年1月-2023年12月,0.5°×0.5°分辨率)是基于月度降水和潜在蒸散发(PET)数据计算的全球气候数据集,专门用于中期干旱监测和分析。SPEI-03以3个月为时间尺度,更适合评估农业和生态系统的长期干旱风险。 数据集采用NetCDF格式,包含时间、空间坐标和SPEI值(无量纲)。负值表示干旱,正值表示湿润,数据经过插值和偏差矫正,确保高时空一致性。基于全球气象观测和重分析数据,如ERA5。 应用场景: 干旱监测:识别全球干旱事件的强度和持续时间。 气候变化研究:评估干旱风险和气候变化的长期影响。 农业与生态管理:支持农作物种植和生态系统保护。 水资源与灾害防治:优化水资源分配和干旱灾害应对。 该数据集为干旱风险评估和气候变化研究提供重要支持,广泛应用于环境、农业、生态和气候预测领域。
基于java的北关村基本办公管理系统设计与实现
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
设计和仿真了一个用于控制化学反应器温度和浓度的多变量控制系统