如何使用javascript验证gridview文本框 [英] how to validate gridview textboxes by using javascript

查看:61
本文介绍了如何使用javascript验证gridview文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有文本框都在模板字段的itemtemplate中,我希望该字段应该是强制使用javascript,



请帮助我。

解决方案

试试这个: -



  <   html     xmlns   =  http://www.w3.org/1999/xhtml   >  
< head >
< title > Untitled Page < / title >
< span class =code-keyword>< script type = text / javascript >
<! -
函数RegainFocus(){
if((document.getElementById(txt)。value)。length == 0){
document.getElementById(txt)。focus ();
alert(文本框不应为空);
}
}
//
- >

< / script >
< / head >
< body >
< 表格 id = frm >
< 输入 type = text id = txt >
< 输入 类型 = 按钮 value = 点击 onclick = javascript:RegainFocus(); / >
< / form >
< / body >
< / html >


all textbox is in itemtemplate of template field,i want to that field should make compulsory by using javascript,

please help me.

解决方案

Try This one :-

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <script type="text/javascript">
    <!--
        function RegainFocus() {
            if((document.getElementById("txt").value).length == 0) {
                document.getElementById("txt").focus();
                alert("The textbox should not be empty");
            }
        }
    //-->
    </script>
</head>
<body>
    <form id="frm">
        <input type="text" id="txt" >
<input type="button" value=" Click " onclick="javascript:RegainFocus();"/>
    </form>
</body>
</html>


这篇关于如何使用javascript验证gridview文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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