---
title: "jquery validate remote方式"
author: "darklipeng"
date: "2011-12-21T18:02:32Z"
tags: []
categories: ["Web前端"]
slug: "jquery-validate-remote"
draft: false
lastmod: "2011-12-21T18:04:54Z"
id: 1319909
url: "https://darklipeng.iteye.com/blog/1319909"
---

需要首先下载jquery.metadata.js和jquery.validate.js

```
	@RequestMapping("/hasexists")
	public @ResponseBody String hasexists(@RequestParam String type) {
		Rule rule = ruleDao.findUniq("type", type);
		if(rule!=null)
		{
			return "false";
		}
		else
		{
			return "true";
		}
	}
	
```

 

```
			<p>
				<label>类型：</label>
				<input id="type" name="type" class="required {remote:'payment/rule/hasexists',messages:{remote:'该类型已被使用'}}" type="text" size="20" />
			</p>
```

 

显示结果：

![](/upload/picture/pic/104794/bf3218bf-4772-36c0-b765-8fbf96122fcf.jpg)