M
Matthew Wieder
Hi - I'm trying to do client-side validation of the text in a Asp.Net
textbox control using javascript. My page has the following:
<form id="Form1" method="post" runat="server" onsubmit="return
validateName(this);">
and
<script language="JavaScript"><!--
function validateName(theForm)
{
var reEval = new RegExp("[\\\/\:\*?\"\<\>|]", "i");
blnEval = reEval.test(theForm.txtName.Value)
if (blnEval)
{
alert("A Valid name must not contain any of the characters
\\/:*?\"<>|");
return false;
}
else
{
return true;
}
}
//--></script>
where txtName is the id in the <asp:TextBox tag. Problem is
1) The theForm.txtName.Value always gives undefined as the value instead
of the actual valus in the textbox.
2) When the Javascript returns true, the page does not submit.
Help anyone?
thanks!
textbox control using javascript. My page has the following:
<form id="Form1" method="post" runat="server" onsubmit="return
validateName(this);">
and
<script language="JavaScript"><!--
function validateName(theForm)
{
var reEval = new RegExp("[\\\/\:\*?\"\<\>|]", "i");
blnEval = reEval.test(theForm.txtName.Value)
if (blnEval)
{
alert("A Valid name must not contain any of the characters
\\/:*?\"<>|");
return false;
}
else
{
return true;
}
}
//--></script>
where txtName is the id in the <asp:TextBox tag. Problem is
1) The theForm.txtName.Value always gives undefined as the value instead
of the actual valus in the textbox.
2) When the Javascript returns true, the page does not submit.
Help anyone?
thanks!