---
title: "GWT client 端验证"
author: "ocaicai"
date: "2011-12-31T09:45:01Z"
tags: ["GWT", "正则表达式", "验证"]
categories: ["Web前端"]
slug: "gwt-client"
draft: false
lastmod: "2011-12-31T09:46:26Z"
id: 1331186
url: "https://ocaicai.iteye.com/blog/1331186"
---

```java

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;
	}


```






.