473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Thoughts on the best way of highlighting form input errors?

I've been creating an application over the last few weeks and generally
pleased with what I have produced but one area is irritating me, form
validation.

At the moment the forms are simply static html templates and the form input
is checked using a validation class. Basically each form field is checked,
every error is stored to an array and at the end of checking of the complete
form, the array is output neatly at the top of the form.

However this is just not sexy enough for me, what I would like to happen is
for the input boxes with errors to be highlighted with a red border (or
something along those lines). I would also like to have the error messages
under the box which the error occured, not altogether at the top of the
page.

So I am currently wondering how to achieve this and what choices are open to
me on methods available? I've had a google around the web and found some
form validation classes but they basically do what I already achieved. I've
thought of creating the forms dynamically but that in itself doesn't address
how to achieve my goal.

I am sure many people have already successfully done this, if you have the
please could give me an outline (the theory) of how you did it. I don't want
or need code, I am simply stuck at the moment on how to approach this.

Cheers

Phil

Mar 3 '07 #1
8 2758
Following on from Phil Latio's message. . .
>At the moment the forms are simply static html templates and the form input
is checked using a validation class. Basically each form field is checked,
every error is stored to an array and at the end of checking of the complete
form, the array is output neatly at the top of the form.
After weeding anything that might be XSS :)
>
However this is just not sexy enough for me, what I would like to happen is
for the input boxes with errors to be highlighted with a red border (or
something along those lines). I would also like to have the error messages
under the box which the error occured, not altogether at the top of the
page.
Basic principle that I use is two pronged

1
Flag the page with a big banner "Something's wrong"

2
Put in a yellow background to the input control (eg switch the css class
of the control)
There are two things that you'll need to pick up on

1
Dynamically generated pages are the way to go and are not difficult to
master.

2
You should have enough 'how to fill in this field' information already
displayed on the form so in general you don't need specific extra error
information. If there are lots of errors then that indicates poor UI
design. Sometimes there are messages that you want to display that are
more than how to type the date in properly. For these you need *more*
than a 'bzzzt wrong' indication. For example suppose you are asking for
a six digit reference number then field highlighting might be
appropriate for the wrong number of digits, a permanent 'where to find
your reference number' help message and a 'sorry we don't have anything
for that reference number pop-up or page - _with what happens next_
clearly explained.

--
PETER FOX Not the same since the bookshop idea was shelved
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Mar 3 '07 #2
Phil Latio wrote:
I've been creating an application over the last few weeks and generally
pleased with what I have produced but one area is irritating me, form
validation.

At the moment the forms are simply static html templates and the form input
is checked using a validation class. Basically each form field is checked,
every error is stored to an array and at the end of checking of the complete
form, the array is output neatly at the top of the form.

However this is just not sexy enough for me, what I would like to happen is
for the input boxes with errors to be highlighted with a red border (or
something along those lines). I would also like to have the error messages
under the box which the error occured, not altogether at the top of the
page.

So I am currently wondering how to achieve this and what choices are open to
me on methods available? I've had a google around the web and found some
form validation classes but they basically do what I already achieved. I've
thought of creating the forms dynamically but that in itself doesn't address
how to achieve my goal.

I am sure many people have already successfully done this, if you have the
please could give me an outline (the theory) of how you did it. I don't want
or need code, I am simply stuck at the moment on how to approach this.

Cheers

Phil

Using a template system for my forms, I do the following:

1) I have variables for setting the STYLEs of my input controls
2) I have variables for setting any extra info if needed

example:

First name: <input style="background-color: {pgfirstname_color};"
type="text" name="pgfirstname" maxlength="25" value="{pgfirstname}">
{pgfirstname_error}

....when resolved, if any variable (placeholder {}) resolves to "" then
the default value is used. So in this example the first time into the
form the variables are set to empty strings "" and the form looks
normal. After validation I set variables accordingly so that:

1) {pgfirstname_color} = "yellow"
2) {pgfirstname} = what the user entered minus invalid stuff that could
cause problems - so they can see the problem.
3) {pgfirstname_error} = a description of the error ("Invalid
characters!", "We really need your first name!", etc.)

results:

no entry:
First name: blank yellow text input We really need your first name!

invalid chars:
First name: N0rman (yellow background) Invalid characters!

This can be done alot more dynamically, I just chose not too.

Norm
Mar 3 '07 #3
Hello,

on 03/02/2007 11:09 PM Phil Latio said the following:
At the moment the forms are simply static html templates and the form input
is checked using a validation class. Basically each form field is checked,
every error is stored to an array and at the end of checking of the complete
form, the array is output neatly at the top of the form.

However this is just not sexy enough for me, what I would like to happen is
for the input boxes with errors to be highlighted with a red border (or
something along those lines). I would also like to have the error messages
under the box which the error occured, not altogether at the top of the
page.

So I am currently wondering how to achieve this and what choices are open to
me on methods available? I've had a google around the web and found some
form validation classes but they basically do what I already achieved. I've
thought of creating the forms dynamically but that in itself doesn't address
how to achieve my goal.

I am sure many people have already successfully done this, if you have the
please could give me an outline (the theory) of how you did it. I don't want
or need code, I am simply stuck at the moment on how to approach this.
You may want to take a look at this forms generation and validation class.

Among other things, it can highlight invalid inputs with an alternative
CSS class or individual style attributes. It can generate Javascript to
highlight invalid fields on the browser side or server side.

You can set a global invalid class or style or different invali classes
or styles for different inputs.

http://www.phpclasses.org/formsgeneration

Take a look here at the test_form.php script in action:

http://www.meta-language.net/forms-e...mple=test_form

Here you can see a tutorial video with a section that explains that example:

http://www.phpclasses.org/browse/vid...mple-form.html
--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Mar 4 '07 #4
Here you can see a tutorial video with a section that explains that
example:

http://www.phpclasses.org/browse/vid...mple-form.html
I am currently enjoying your audio/visual presentation. I have actually
started listening from the beginning.

Not made any decisions on what direction I am going to take but I did also
like your example form. I don't like pop-up windows (purely personal
preference) but will certainly have a look at the code once I've finished
viewing the video.

Cheers

Phil
Mar 4 '07 #5

"Phil Latio" <ph********@f-in-stupid.co.ukwrote in message
news:B1********************@fe07.news.easynews.com ...
>Here you can see a tutorial video with a section that explains that
example:

http://www.phpclasses.org/browse/vid...mple-form.html

I am currently enjoying your audio/visual presentation. I have actually
started listening from the beginning.

Not made any decisions on what direction I am going to take but I did also
like your example form. I don't like pop-up windows (purely personal
preference) but will certainly have a look at the code once I've finished
viewing the video.
Had a bit of look at your package but it's not for me as I like to totally
seperate mark-up/presentation from the code. However I salute you on your
efforts and the audio/visual presentation is a great idea if perhaps a
little long winded.

Thanks again for your input.

Cheers

Phil
Mar 4 '07 #6
On Mar 5, 3:00 am, "Phil Latio" <phil.la...@f-in-stupid.co.ukwrote:
"Phil Latio" <phil.la...@f-in-stupid.co.ukwrote in message

news:B1********************@fe07.news.easynews.com ...
Here you can see a tutorial video with a section that explains that
example:
>http://www.phpclasses.org/browse/vid...ion/example-fo...
I am currently enjoying your audio/visual presentation. I have actually
started listening from the beginning.
Not made any decisions on what direction I am going to take but I did also
like your example form. I don't like pop-up windows (purely personal
preference) but will certainly have a look at the code once I've finished
viewing the video.

Had a bit of look at your package but it's not for me as I like to totally
seperate mark-up/presentation from the code. However I salute you on your
efforts and the audio/visual presentation is a great idea if perhaps a
little long winded.

Thanks again for your input.

Cheers

Phil
Maybe you can take a look at PEAR:Quickform. It accepts Smarty as
renderer so you can couple the two together and separate the markup
from the application logic. Also if you are willing maybe you can test-
drive the code-lib i created using PEAR and some other useful classes
and wrapped them around a simple Controller. You can download it from
here and run the setup file in the setup folder or change the config
file manually.

http://www.esnips.com/doc/356a32f6-1.../tuxedo-ver0.1

Mar 6 '07 #7
Hello,

on 03/04/2007 07:00 PM Phil Latio said the following:
>>Here you can see a tutorial video with a section that explains that
example:

http://www.phpclasses.org/browse/vid...mple-form.html
I am currently enjoying your audio/visual presentation. I have actually
started listening from the beginning.

Not made any decisions on what direction I am going to take but I did also
like your example form. I don't like pop-up windows (purely personal
preference) but will certainly have a look at the code once I've finished
viewing the video.

Had a bit of look at your package but it's not for me as I like to totally
seperate mark-up/presentation from the code. However I salute you on your
Maybe it was not clear for you, but the class gives you complete freedom
to separate markup presentation from code. For instance, if you prefer
to use Smarty to define your forms presentation, the class comes a
plug-in to integrate with Smarty template engine.

If you watch this video section to the end, you see it provides
different form rendering alternatives to match the preferences of
different people:

http://www.phpclasses.org/browse/vid...templates.html

If you do not want to write any HTML at all, there is also an
alternative renderer plug-in that uses a common vertical layout with one
field per row.

efforts and the audio/visual presentation is a great idea if perhaps a
little long winded.
This class is very popular because it covers a long list of needs of
many different people. That is why it took a 4 hour video to give a
tutorial to explain all it does.

--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Mar 6 '07 #8
Hello,

on 03/04/2007 02:07 PM Phil Latio said the following:
>Here you can see a tutorial video with a section that explains that
example:

http://www.phpclasses.org/browse/vid...mple-form.html

I am currently enjoying your audio/visual presentation. I have actually
started listening from the beginning.

Not made any decisions on what direction I am going to take but I did also
like your example form. I don't like pop-up windows (purely personal
preference) but will certainly have a look at the code once I've finished
viewing the video.
That pop-up window is a Javascript alert box. It appears in the video
because the example uses browser side validation along with server side
validation. You can disable browser side validation and the alert box
never appears because the server side validation displays errors in the
HTML page.

Anyway, a plug-in to intercept browser side validation errors is being
implemented so you can customize how the error messages will appear in
the browser even before it is submitted to the server.

--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Mar 6 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Adelson Anton | last post by:
Hi all, Ok, this is what I want to do: When you press, say Ctrl+K ( it doesn't matter which event), I want the , say, second word in the document to be highlighted. Anyone has any idea how...
4
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax...
35
by: Justin Weinberg | last post by:
My thoughts on this.... http://msdn.microsoft.com/vbasic/Future/default.aspx?pull=/library/en-us/dnvs05/html/vb9overview.asp My thoughts: 1. Regarding Implicit types, I don't use type...
9
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be...
7
by: h7qvnk7q001 | last post by:
I'm trying to implement a simple server-side form validation (No Javascript). If the user submits a form with errors, I want to redisplay the same form with the errors highlighted. Once the form...
6
by: Zim Babwe | last post by:
VS 2005 Windows Application I need to have users enter product information, then contact information, then some other financial information. Currently I have a form that the user enters info...
1
by: Muchach | last post by:
Hello, Ok so what I've got going on is a form that is populated by pulling info from database then using php do{} to create elements in form. I have a text box in each table row for the user to...
5
by: Lea GRIS | last post by:
Hello, Are there any generic and CSS standard mean of highlighting an accesskey? I only fond a workaround by encapsulating the corresponding letter in a <em></eminside the label. But it is not...
1
by: chromis | last post by:
Hi, I'm having trouble fully implementing the edit section of a contact admin system, so far I have written the following: - Bean (Contact.cfc) - Data Access object (ContactDAO.cfc) - Gateway...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.