Hi, Please can you tell me how to get a simple form validation function to write the error to the page and not to an alert box. Using document.write() in the javacsript function seems to write the error in a different page - I want the message to appear at the top of the form, and still show the original form elements, and position the cursor in the field that had illegal input. Many thanks,
and also my validation utility. I have a version that writes messages on the screen, but it is not finished, it should be on the main page to my validation utility. I have not fixed it with CSS support and multiple validations per element. Eric
Bear Bibeault
Author and opinionated walrus
Marshal
As Eric pointed out, it's pretty simple to use the innerHTML property to add things to a page dynamically. I'd create an empty and hidden div where you want the error messages to appear, and upon detection of failure, fill the div with the messages and show the div. Be aware however that innerHTML, even thought it works just fine in most moderne browsers, is not a w3c standard. If you are concerned with standards compliance you need to go down the route of DOM manipulation, which is not only standards-compliant, but is also much more powerful (as well as confusing). Here is the DOM reference that I use. Personally, I'd give the innerHTML route a try first. Them once that is working, decide if that's sufficient for your needs. hth, bear