如果用户将该字段留为空白,然后单击另一个字段,则需要通过一条错误消息. [英] I need to through an error message, if the user left the field blank and clicks on another field.

查看:107
本文介绍了如果用户将该字段留为空白,然后单击另一个字段,则需要通过一条错误消息.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的应用程序中,我有一个名称字段(txtname),用户名字段(txtusername)等.我为两者都插入了必填字段验证,当我们单击按钮(提交)时,必填字段验证程序工作正常.但是这里我的要求是,如果用户不输入上一个字段(意味着他将txtname留空,然后输入下一个字段的数据,例如txtusername),那么此时它必须立即通过一条错误消息(例如您可以")不要将此留空.").就像在gmail创建帐户中一样,使用了这种想法.就像我一样,我也想这样做.请帮我解决这个问题.

抱歉,有任何错误或无法理解.

Hi,

In my application I have a name field (txtname), username field(txtusername),etc. I have inserted a required field validations for both, the required field validator is working fine when we click on the button(submit). But here my requirement is, if the user not enter the previous field (means he left blank of txtname and entering the data for next field say txtusername), at that time it has to immediately through an error message (like "You can''t leave this empty."). Like in gmail create account this idea is used. Like wise i want do the same. Please help me out regarding this.

Sorry for any errors or not understanding.

推荐答案


您需要使用JavaScript验证来显示警报框.请按照以下链接使用JavaScript进行验证:
http://www.w3schools.com/js/js_form_validation.asp [ http://www.javascript-coder.com/html-form/javascript-form- validation.phtml [^ ]
http://www.tizag.com/javascriptT/javascriptform.php [
Hi,
You need to use JavaScript validation to show the alert box. Follow the links below to perform validation using JavaScript:
http://www.w3schools.com/js/js_form_validation.asp[^]
http://www.javascript-coder.com/html-form/javascript-form-validation.phtml[^]
http://www.tizag.com/javascriptT/javascriptform.php[^]

All the best.
--Amit


您必须为控件设置Causesvalidation = true.这样,当您将焦点从一个控件移到另一个控件时,它将验证先前的控件.
You have to set causesvalidation=true for the controls. So that when you move focus from one control to other, it will validate previous controls.


这篇关于如果用户将该字段留为空白,然后单击另一个字段,则需要通过一条错误消息.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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