Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Client-Side Validation of asp:TextBox with Javascript

Reply
Thread Tools

Client-Side Validation of asp:TextBox with Javascript

 
 
Matthew Wieder
Guest
Posts: n/a
 
      07-23-2003
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!

 
Reply With Quote
 
 
 
 
Vidar Petursson
Guest
Posts: n/a
 
      07-23-2003
Hi

A quick glance
theForm.txtName.value <---- value not Value

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
"Matthew Wieder" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!
>



 
Reply With Quote
 
 
 
 
Matthew Wieder
Guest
Posts: n/a
 
      07-23-2003
OK, you win points for the fast valid reply to part one of my problem -
anybody know why the form wont submit?

Vidar Petursson wrote:
> Hi
>
> A quick glance
> theForm.txtName.value <---- value not Value
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A form validation library with javascript validation Grigory Temchenko Python 0 12-28-2008 08:38 PM
Need your help, I am new with javascript, what do I wrong? javascript form validation suddenly doesn´t work francisco lopez Javascript 2 12-30-2004 12:18 PM
Web form validation vs object validation Colin Basterfield ASP .Net 1 11-29-2003 12:10 AM
validation summary doesnt display when there's client-side validation Libs ASP .Net 0 06-25-2003 03:05 PM
Re: only custom validation control does server side validation? Colin Mackay ASP .Net 0 06-25-2003 07:54 AM



Advertisments