我必须用于下拉列表的验证是什么? [英] what is the validation that i have to use for dropdown list?

查看:117
本文介绍了我必须用于下拉列表的验证是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户未从下拉列表中选择任何选项,我必须对下拉列表使用哪种验证?

解决方案

使用RequiredFieldValidator并设置RequiredFieldValidator的初始值属性(通常为选择").

希望对您有帮助:)


您还可以使用Javascript查看selectedIndex.如果它是"-1"(如果未选择任何内容)或"0"(如果选择了选择"选项),则显示警报并且不允许提交.

-1或0将取决于您如何实现下拉菜单.


如其他人所述,或者设置默认值.


What kind of validation do I have to use for dropdown list if the user did not select any option from the dropdown list?

解决方案

Use RequiredFieldValidator and set the initial value property of RequiredFieldValidator( usually this will be ''Select'').

Hope this will help you :)


You can also use Javascript to see the selectedIndex. If it''s ''-1''(if nothing is selected) or ''0''(if option ''Select'' is selected) then show alert and not allow the submit.

-1 or 0 would be based on how you have implemented the dropdown.


As the others have stated, or, alternatively, set a default.


这篇关于我必须用于下拉列表的验证是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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