Highlight Required Field When Not Validated

S

Steve Murphy

I'd like to highlight any required fields that don't pass validation by
changing their labels to red, and I prefer to do this client-side. I was
hoping to do this with a CustomValidator, but the client-side script doesn't
run unless there's actually a value in the field. Any suggestions? Is there
any other way to do a client-side validation before calling my save method
on the server?

Thanks in advance.
 
S

sam

My suggestion is to modify or replace the offending Microsoft client
side code to not check for an empty value. This is what we did where I
work.

My understanding is that in ASP.NET 2.0 they have an option that allows
this. Maybe you can use that instead.
 
S

Steve Murphy

sam said:
My suggestion is to modify or replace the offending Microsoft client
side code to not check for an empty value. This is what we did where I
work.

Where do you do that?

My understanding is that in ASP.NET 2.0 they have an option that allows
this. Maybe you can use that instead.

I'm not using 2.0 at this time.


Thanks for the reply.
 
S

sam

Its in WebUIValidation.js which will be under your Inetpub directory a
couple folders down. Just trace the functions starting with
Page_ClientValidate or whatever its called in the __doPostback
javascript function which you can see by doing a view page source.

Easiest way to see the offending line is to set a break point in the
aforementioned function and just step into the javascript functions
when the empty textbox doens't get validated (I remember the function
is called CustomValidate or something like that).

Anyway, its pretty straightforward. At work here all of our postback
controls call TPageClient_Validate() rather than the one ASP.NET one.
Most of our javascript funcitons are copied from ASP.NET except for
little changes like you've noticed. But there is no reason why you
can't simply edit the WebUIValidation.js file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top