Textboxvalidation:空或最小3个字符(空格不计) [英] Textboxvalidation: Empty or minimum 3 characters (spaces do not count)

查看:146
本文介绍了Textboxvalidation:空或最小3个字符(空格不计)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我使用的是搜索领域的一些文本框。
文本框可以是空的,但是当一个搜索准则被填充,它必须至少有3个字符,忽略了计数的空格。

I have some textboxes I'm using as search-fields. The textbox can be empty, but when a search-criteria is filled in, it must be at least 3 characters long, ignoring the spaces in the count.

我发现,当文本框为空,一个regularex pressionvalidator验证真实的,所以这部分是确定的。

I've found that a regularexpressionvalidator validates true when the textbox is empty, so that part is ok.

问:正则表达式为3个字符的minimumlenth。空间是允许的,但不应该在长度计数。

Q: regex for a minimumlenth of 3 characters. Spaces are allowed, but should not count in the length.

感谢。

推荐答案

你有没有尝试过这样的事情?

Have you tried something like this?

'(\s*\w\s*){3}'

这经常EX pression寻找一个字符( \\ W )任选通过任何空白surronded( \\ s * )的三倍( {3} ),这是你在找什么。

This regular expression looks for a character (\w) optionally surronded by any whitespace (\s*) three times ({3}), which is what you're looking for.

请注意:我不知道asp.net,但我认为常规的前pression是所有你需要解决的问题。

Note: I don't know asp.net, but I think the regular expression is all you need to solve the problem.

这篇关于Textboxvalidation:空或最小3个字符(空格不计)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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