![]() |
Help with ALERTs.
Hello people. I have a small exersize which I can't complete without gaining a little knowledge on a certain subject first..
The subject is Alerts. I'm trying to Validate Several feilds in a registration form. And I need to return to the user the various errors that occured while attempting to register. It would be easier to just do it 1 alert at a time. But that would be extremely lame and unacceptable, on a professional site it would be funny. I need to know how I can Sum up all the errors, and display them in one alert. For example, my name is too short, and my address is too short. An alert comes up saying "The following errors occured: Name too short Address too short" In this registry form though, there are at least 15 feilds. Does someone know of a simple way to explain how to do this? Thanks. any links are welcome if you know of a place explaining it, I couldn't find much though. :) |
Highlight the fields in error (for instance, change the background to light red).
|
I need help understanding how to do this with ALERTS. So far I have no code really besides the original HTML code. The basic idea, is that it sums up the errors and puts it in one alert. Instead of showing several alerts. That's what I need to do, and the part I havn't figured out yet.
|
Make an empty string. Each validator, if it finds an error, appends its message to the string. The concatenation operator is +.
You are going to force your user to memorize the list before he/she dismisses the alert? :rolleyes: On a professional site, that would be funny. |
I know I'm just trying to get a point across :O Thanks by the way I'm trying out what you said now.
|
Like this?
alert ("The following errors occured: " + check); How do you think I could write the function that that concatonates the errors into "check" ? |
This is pseudo code, untested on a page. Presume three fields: name, address, and email. The are validated onblur or onchange, or something suitable. Variable "errors" is initially set to "The following errors occurred: \n".
:
function validateName () |
| All times are GMT -5. The time now is 2:48 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC