Problem regarding asp.net validation controls and javascript

Problem regarding asp.net validation controls and javascript

Post by shailendra deshpand » Thu, 30 Apr 2009 00:50:01



Dear all

I have one query regarding validation controls and javascript used in
asp.net c#.
I have form on which i have one textbox, required field validator and
one button.
I wrote a javascript to check the textbox length and assign that
javascript function to a button on page_load(), the button also has
"required field validator" assigned to it.
at first time when i press the button the required field validator
dosent work. and javascript function which returns true because it
cheks the length > 10.
when i take out the assigned javascript the required field validator
works.

I want that required field validator works first then javascript
function to check length.

Please give me the solution

 
 
 

Problem regarding asp.net validation controls and javascript

Post by Vivek SHANTHARA » Thu, 30 Apr 2009 01:27:54


Its obvious JS is called first , because Javascipt is processed at client
side and the required field validator is a server side control.

The solution is to perform what teh required field validator does, in
javascript itself. if you want to check for any empty space in textbox , u
can use some condition like

if(document.getelementbyid["tbxUrControl"].value == "")

hope this helps.

there are many javascripts available for this validation tasks. check out in
google

regards
Vivek.

On Tue, Apr 28, 2009 at 9:20 PM, shailendra deshpande <


> Dear all

> I have one query regarding validation controls and javascript used in
> asp.net c#.
> I have form on which i have one textbox, required field validator and
> one button.
> I wrote a javascript to check the textbox length and assign that
> javascript function to a button on page_load(), the button also has
> "required field validator" assigned to it.
> at first time when i press the button the required field validator
> dosent work. and javascript function which returns true because it
> cheks the length > 10.
> when i take out the assigned javascript the required field validator
> works.

> I want that required field validator works first then javascript
> function to check length.

> Please give me the solution


 
 
 

Problem regarding asp.net validation controls and javascript

Post by Cerebru » Thu, 30 Apr 2009 02:33:35


Show us the ***rendered portion*** of your ASPX page, specifically the
HTML of the button.



Quote:> Dear all

> I have one query regarding validation controls and javascript used in
> asp.net c#.
> I have form on which i have one textbox, required field validator and
> one button.
> I wrote a javascript to check the textbox length and assign that
> javascript function to a button on page_load(), the button also has
> "required field validator" assigned to it.
> at first time when i press the button the required field validator
> dosent work. and javascript function which returns true because it
> cheks the length > 10.
> when i take out the assigned javascript the required field validator
> works.

> I want that required field validator works first then javascript
> function to check length.

> Please give me the solution

 
 
 

Problem regarding asp.net validation controls and javascript

Post by Cerebru » Thu, 30 Apr 2009 02:36:14


Vivek,

You seem to be assuming that the OP has EnableClientScript turned off
and is exclusively validating on the server. My experience would
suggest otherwise because it is True by default and 99% fellas don't
mess with defaults unless they absolutely have to ! ;-)


> Its obvious JS is called first , because Javascipt is processed at client
> side and the required field validator is a server side control.

> The solution is to perform what teh required field validator does, in
> javascript itself. if you want to check for any empty space in textbox , u
> can use some condition like

> if(document.getelementbyid["tbxUrControl"].value == "")

> hope this helps.

> there are many javascripts available for this validation tasks. check out in
> google

> regards
> Vivek.

> On Tue, Apr 28, 2009 at 9:20 PM, shailendra deshpande <


> > Dear all

> > I have one query regarding validation controls and javascript used in
> > asp.net c#.
> > I have form on which i have one textbox, required field validator and
> > one button.
> > I wrote a javascript to check the textbox length and assign that
> > javascript function to a button on page_load(), the button also has
> > "required field validator" assigned to it.
> > at first time when i press the button the required field validator
> > dosent work. and javascript function which returns true because it
> > cheks the length > 10.
> > when i take out the assigned javascript the required field validator
> > works.

> > I want that required field validator works first then javascript
> > function to check length.

> > Please give me the solution- Hide quoted text -

> - Show quoted text -