>
input a number:<br>
<input type="text" name="number"><p>
input a emial:<br>
<input type="text" name="email"><p>
input a telephone:<br>
<input type="text" name="tel"><p>
input a string (length should between 6-8):<br>
<input type="text" name="strlen"><p>
input a string (shoulde not contain "jeru"):<br>
<input type="text" name="nojeru"><p>
input a string (must contain "jeru"):<br>
<input type="text" name="jeru"><p>
input a date (yyyy-mm-dd):<br>
<input type="text" name="date"><p>
<br><input type="submit" name="submit" value="go">
</form>
</body>
</html>
===================================== ErrorCheck.java =====================================
package dbclass;
/**
* ErrorCheck v 1.0
*
* 这个类是用来在客户端生成 JavaScript 代码来校验表单的
* 原是版本是同事 Macro 用 PHP 写的,我感觉十分好用,再也
* 不用再为那些表单区写烦人的 javascript 代码拉,感谢他!
* 这次我用 Java 改写,封装成一个类,并修复了少许的 bug,加
* 多了一条校验的功能,它的扩展性很好,以后可能会继续完善。
*
* Mender :
* Jeru Liu
* Homepage :
* http://www.cyberlabs.com/~jeru/
* Email: jeru@163.net
*
*/
import java.io.*;
public class ErrorCheck {
/* public: the javascript string */
String errorCheckStr;
/* public: the form name you used */
public String formName;
public void setFormName(String formName) {
this.formName = formName;
}
/***************************************************************************\
* public: constructor functions
* 构造函数
\***************************************************************************/
public ErrorCheck() {
this.errorCheckStr =
"<script ID=clientEventHandlersJS language=javascript>" + "\n" +
"<!--" + "\n";
this.neededFunction(); // load the needed functions
this.errorCheckStr +=
"function errorCheck() {" + "\n";
}
/***************************************************************************\
*&
input a number:<br>
<input type="text" name="number"><p>
input a emial:<br>
<input type="text" name="email"><p>
input a telephone:<br>
<input type="text" name="tel"><p>
input a string (length should between 6-8):<br>
<input type="text" name="strlen"><p>
input a string (shoulde not contain "jeru"):<br>
<input type="text" name="nojeru"><p>
input a string (must contain "jeru"):<br>
<input type="text" name="jeru"><p>
input a date (yyyy-mm-dd):<br>
<input type="text" name="date"><p>
<br><input type="submit" name="submit" value="go">
</form>
</body>
</html>
===================================== ErrorCheck.java =====================================
package dbclass;
/**
* ErrorCheck v 1.0
*
* 这个类是用来在客户端生成 JavaScript 代码来校验表单的
* 原是版本是同事 Macro 用 PHP 写的,我感觉十分好用,再也
* 不用再为那些表单区写烦人的 javascript 代码拉,感谢他!
* 这次我用 Java 改写,封装成一个类,并修复了少许的 bug,加
* 多了一条校验的功能,它的扩展性很好,以后可能会继续完善。
*
* Mender :
* Jeru Liu
* Homepage :
* http://www.cyberlabs.com/~jeru/
* Email: jeru@163.net
*
*/
import java.io.*;
public class ErrorCheck {
/* public: the javascript string */
String errorCheckStr;
/* public: the form name you used */
public String formName;
public void setFormName(String formName) {
this.formName = formName;
}
/***************************************************************************\
* public: constructor functions
* 构造函数
\***************************************************************************/
public ErrorCheck() {
this.errorCheckStr =
"<script ID=clientEventHandlersJS language=javascript>" + "\n" +
"<!--" + "\n";
this.neededFunction(); // load the needed functions
this.errorCheckStr +=
"function errorCheck() {" + "\n";
}
/***************************************************************************\
*&
| 对此文章发表了评论 |
