关于正则表达式验证器的帮助 [英] help regarding Regular expression validator

查看:102
本文介绍了关于正则表达式验证器的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net中使用正则表达式验证,该验证指向文本框.

我想知道以下情况的正则表达式是什么

如果只输入%作为第一个字符,则不允许这样做

如果%后跟任何其他字符,则应允许它.

应该允许是否在开头输入其他字符.



2)

I am using regular expression validation in asp.net which points to a textbox.

I want to know what will be the regex for the following case

It should not allow if only % is entered as first character

If % is followed by any other characters it should allow it.

It should allow if other characters are entered in the beginning.



2)
Is it possible to display the validation error in another message box type in a webpage?

推荐答案

简单:
%.+|[^%].*

如果匹配,就可以.如果不是,那就不是.

是的,您可以-我建议您使用Javascript进行验证( ^ ]可以为您提供帮助),如果您要这样做的话,只需为每个字符保存更新->服务器,检查->响应"周期即可.

获取 Expresso [ ^ ]-它是免费的,它可以检查并生成正则表达式.

If it matches, it''s ok. If it doesn''t, it isn''t.

Yes, you can - I would suggest doing the validation in Javascript (Google[^] can help you there) if you are going to do that, just to save "updates -> server, check -> respond" cycles for each character.

Get a copy of Expresso [^] - it''s free, and it examines and generates Regular expressions.


这篇关于关于正则表达式验证器的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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