jQuery带水印的输入和验证 [英] jQuery Watermarked input and validation

查看:114
本文介绍了jQuery带水印的输入和验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在HTML页面上,我有一个输入框,当它为空时,上面有一个水印". (例如:在此处输入文字...").有点像这样: http://digitalbush.com/projects/watermark-input-plugin/-但自定义编写.

On a HTML page I have an inputbox that has a 'watermark' on it when it is empty. (eg: "enter text here..."). Kind of like this: http://digitalbush.com/projects/watermark-input-plugin/ - but custom written.

问题是我无法弄清楚如何使用jQuery验证插件来验证此字段( http://docs.jquery.com/Plugins/Validation/),以便它将我的水印文本视为该字段为空.

The problem is that I can't figure out how to validate this field with the jQuery validation plugin (http://docs.jquery.com/Plugins/Validation/) so that it treats my watermark text as if the field was empty.

我无法在jQuery验证器中找到一个选项来让我为字段有效时指定自定义规则,是否有一个?我可以找到一些选项,这些选项可以让我指定是否需要基于自定义逻辑来验证字段 ,而不是如何验证该字段.

I can't find an option in the jQuery validator to let me specify a custom rule for when a field is valid, is there one? I could find options that allow me to specify whether a field needs to be validated based on custom logic, but not how it should be validated.

我想念什么?

推荐答案

查看此博客文章:

http://randomactsofcoding.blogspot .com/2008/10/starting-with-jquery-how-to-write.html

告诉您如何为字段构造自定义验证规则.

Tells you how to construct a custom validation rule for a field.

这篇关于jQuery带水印的输入和验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆