使用javascript验证asp.net中的文本框时出现错误 [英] error coming while validating textboxes in asp.net using javascripts
问题描述
我将以下代码用于文本框验证.
这是我在javascript文件中定义的函数.我这样做是为了确保文本框不应为null,并且文本框应仅包含字母.
i used the following code for textbox validation..
this is the function which i defined in the javascript file.i done this to ensure the textbox should not be null and the textbox should contain only alphabets.
function RegainFocus()
{
if((document.getElementById("TextBox1").value).length == 0 ||
(document.getElementById("TextBox2").value).length == 0 ||
(document.getElementById("TextBox3").value).length == 0||
!document.getElementById("TextBox1").value.match(/^[a-zA-Z]+$/)||
!document.getElementById("TextBox2").value.match(/^[a-zA-Z]+$/)||
!document.getElementById("TextBox3").value.match(/^[a-zA-Z]+$/))
{
alert ("please enter a valid data");
}
}
在表单加载事件中,我将javascript文件称为
in the form load event i called the javascript file as
Page.RegisterClientScriptBlock("MyScript", "<SCRIPT Language='JavaScript' src='JScript.js'></SCRIPT>");
Button1.Attributes.Add("OnClick", "RegainFocus()");
这对我来说是引发错误....."Microsoft JScript运行时错误:必需的对象"
任何人都可以帮我做到这一点..........???
this is throwing error for me....."Microsoft JScript runtime error: Object required"
can anyone plss help me in doing this..........???
推荐答案
/)|| !document.getElementById(" ).值.match(/^ [a-zA-Z] +
/)|| !document.getElementById("TextBox2").value.match(/^[a-zA-Z]+
/)|| !document.getElementById(" ).值.match(/^ [a-zA-Z] +
/)|| !document.getElementById("TextBox3").value.match(/^[a-zA-Z]+
/)) { 警报(" ); } }
/)) { alert ("please enter a valid data"); } }
在表单加载事件中,我将javascript文件称为
in the form load event i called the javascript file as
Page.RegisterClientScriptBlock("MyScript", "<SCRIPT Language='JavaScript' src='JScript.js'></SCRIPT>");
Button1.Attributes.Add("OnClick", "RegainFocus()");
这对我来说是引发错误....."Microsoft JScript运行时错误:必需的对象"
任何人都可以帮助我做到这一点.......... ???
this is throwing error for me....."Microsoft JScript runtime error: Object required"
can anyone plss help me in doing this..........???
这篇关于使用javascript验证asp.net中的文本框时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!