By the way, if you’re just wanting to validate the form without wanting to learn much about the details of how it’s done, there is really good jQuery [form validation plugin from "]form validation](http://docs.jquery.com/Plugins/Validation) that makes it a lot easier.
Phone.name would be BusinessPhone, and Phone.value would be empty.
Once someone types something into the field and submits, then Phone.value would contain what they typed in.
No, I think that you had it better with the previous code. There is absolutely no need to use of text1/text2/text3 inside the ValidatePhone function itself.
What do you mean? I just need more advice on how to show which textboxes have not been filled in using alert message. Secondly, it will show a single “YAY” when all three are filled in correctly.
It sounds like you need to refactor things then, by moving the alerts out of the ValidatePhone fnction and into the ValidateForm function. Then you can use the information on what passed and what didn’t, and add the failed information on to a string, which you would then show at the end of validating all three.
I’ll go through how you would do this, by comparing how the existing code works, as against how you want the code to work.
Currently, the ValidatePhone function shows an alert, and return either true or false.
Currently, the ValidateForm function returns as soon as the ValidatePhone function returns false.
Instead of doing that, you want the ValidatePhone messages to be all added together, and shown at the end as one combined alert.
So, here’s how you will want to change the functions.
You need ValidatePhone to do this instead:
[list][]not do any alerts at all, as that job will be handled higher up
[]when validation fails, return the error message
[*]when validation succeeds, return just an empty string[/list]
You also need the ValidateForm function to do this:
[list][]to string together the returned strings from each of the ValidatePhone functions
[]if the added strings are an empty string, then validation is good
[*]otherwise, you know that the an error has occurred, and you can alert the error[/list]
Those are the refactoring changes that you need to make to your functions. The above two lists can be used as a checklist, as you work towards achieving that design goal.