ITeye博客

GWT client 端验证

ocaicai · 2011-12-31 09:45 · GWT · Web前端 · GWT · 正则表达式 · 验证 · Markdown


import com.google.gwt.regexp.shared.RegExp;

	/** 获取用户设置的当前页码 */
	public int getCurrentaBoxVal() {
		int pageNum = 1;
		String currentPageBoxVal = currentPageBox.getValue().trim();
		String patternStr = "^\\d+$";

		if (null != currentPageBoxVal && currentPageBoxVal.length() > 0) {
			RegExp regExp = RegExp.compile(patternStr);
			boolean matchFound = regExp.test(currentPageBoxVal);
			if (matchFound) {
				pageNum = Integer.valueOf(currentPageBoxVal);
			} else {
				Window.alert("Please input positive integer !");
			}
		} else {
			pageNum = currentPageNumber;
		}

		return pageNum;
	}


.

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。