用于检查网页中文本框是否为空的Java脚本. [英] java script to check if the textboxes in the webpage are empty or not..
本文介绍了用于检查网页中文本框是否为空的Java脚本.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友,
我想知道如何编写Java脚本来检查文本框,下拉列表是否为空.如果它们为空,则应调用css类并在该文本框中显示一条消息. br/>
如果(文档 .getElementById( txtName').value == ')
{}
下拉列表选择是否为空:
< 选择 > ;
< 选项 值 = " > 123 >< /option >
< 选项 =" 234" < >
< /select >
var hasValue =(
(' 选择> [selected]').length> 0 );
Hello Friends,
I want to know how to write a java script to check if the text-boxes, dropdown list are empty or not. And if they are empty it should call a css class and display a message within that text box.
解决方案
Sample JavaScript to validate the text box is empty or not:
if (document.getElementById('txtName').value=='') {}
dropdown list select is empty or not:
<select> <option selected value="123">123</option> <option value="234">234</option> </select>
var hasValue = (
('select > [selected]').length > 0);
这篇关于用于检查网页中文本框是否为空的Java脚本.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文