CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Highlighting invalid form fields

Print topic Send  topic

Author Message
afrausto

Posts: 66
Posted: 10/21/2005, 4:30 PM

Hello,

Has anyone had any luck trying to highlight invalid form fields (textbox, select, textarea, etc...) or changing the text font color of required form fields?

I would like to either change the text font color of the names of the fields or change the background color of invalid form fields, for example textbox, textarea, etc. I've tried to use the Dynamically Modify HTML Output technique but I'm not sure how to compare what fields are invalid when the form is submitted. Or do I have to manually code each error rather than using the Required function?

Anyone come across this before?

Thanks,
Albert
View profile  Send private message
DonB
Posted: 10/21/2005, 7:28 PM

Here's the brief answer: Controls that support validation have an "Error
Control" property. When these are filled in with the name of a control
(e.g., a Label), you have the basis for doing what you required.

By strategically locating that Label within an <INPUT> or <TD> or <TR>
(etc.) and the Error message (from the Validate event) to
'style="font-color:red"', you could make the text of each control that fails
validate turn red.

You could also do an Errors.addError() into the form object to put an error
message such as "Please correct the highlighted items" at the top of the
form.


--
DonB

http://www.gotodon.com/ccbth


"afrausto" <afrausto@forum.codecharge> wrote in message
news:643597a0bc7e27@news.codecharge.com...
> Hello,
>
> Has anyone had any luck trying to highlight invalid form fields (textbox,
> select, textarea, etc...) or changing the text font color of required form
> fields?
>
> I would like to either change the text font color of the names of the
fields or
> change the background color of invalid form fields, for example textbox,
> textarea, etc. I've tried to use the Dynamically Modify HTML Output
technique
> but I'm not sure how to compare what fields are invalid when the form is
> submitted. Or do I have to manually code each error rather than using the
> Required function?
>
> Anyone come across this before?
>
> Thanks,
> Albert
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

afrausto

Posts: 66
Posted: 10/24/2005, 11:44 AM

DonB,

Thanks for the insight into the ErrorControl property. Although, I don't want to lose the error message(s) that would normally appear at the top of the form. Is there a way to determine what form fields have errored after the form has been submitted and then dynamically change the look of the textbox, select, textarea, etc. using a lable and css?

Thanks,
Albert
View profile  Send private message
afrausto

Posts: 66
Posted: 10/25/2005, 9:06 AM

DonB,

Thanks for the suggestion to use the ErrorControl property but that didn't work with <INPUT>, <TD>, or <TR>. The validation text that is substituted for Error Control adds a "<BR>" after it. For instance I tried using 'style="font-color:red"' in <TD> but it was converted to this style="font-color:red"<br> which was not recognized.

Thanks for the suggestion though.

Albert
View profile  Send private message
DonB
Posted: 10/26/2005, 11:58 AM

You can suppress that <BR>, there is an ErrorDelimiter property on the
Errors class. Just set it to an empty string prior to adding an error to
the Errors collection.

--
DonB

http://www.gotodon.com/ccbth


"afrausto" <afrausto@forum.codecharge> wrote in message
news:6435e57ecb97d5@news.codecharge.com...
> DonB,
>
> Thanks for the suggestion to use the ErrorControl property but that didn't
work
> with <INPUT>, <TD>, or <TR>. The validation text that is substituted for
Error
> Control adds a "<BR>" after it. For instance I tried using
> 'style="font-color:red"' in <TD> but it was converted to this
> style="font-color:red"<br> which was not recognized.
>
> Thanks for the suggestion though.
>
> Albert
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

TheunisP

Posts: 342
Posted: 12/28/2005, 4:16 PM

Hi guys, I played with this just now - and inserted a Label/Variable in a TextBox's tag - by then changing the value of the Label/Variable in the controls OnValidate event - almost anything is possible. (I used inline CSS to change the background color)

Problem that I can see with this - that it is pretty time consuming - CCS does make you lazy ;-) - but it does work. To save time I would just maybe highlight all the needed fields if any 1 of them is left out - the user would then at a glance be able to see what went wrong where.

PS. The only problem Ihad with the technique was that for some reason CCS don't see the Control anymore (huh?) and wants to delete it - but if you click No (don't delete) it generates fine and works. I'll just double check my code for mistakes - and contact support if it seems to be a bug - will let you know.

View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.