How do you write text to a specific location on the screen using javascript. I have made a html form and I am using javascript to validate it. I don't want to use a alert box because they are just so annoying, instead I want to write the errors to the screen above the fields that have the error. How do I do that? (using form and or div tags) Thanks. ~Imozeb
Use CSS. Something like this <html> <head> </head> <body> <div name="input" style="width:200px;height:200px;border-style:solid;border-color:#98bf21;border-width:5px;top:150px;position:absolute;left:200px;"> <div style="position:relative;top:-32px;left:22px;"> <b>Da da</b> Or ...<script>javascript:document.write("lol");</script> </div> </div> </body> </html> Code (markup):
I know how to do that but, what I don't know is how to refer to it through my javascript coding in the head tag. <head> <script text/javascript> document.write.... * </script> </head> <body> <input ....../> *(text needs to go here) </body> ~Imozeb
assign a function to the onsubmit event of your form... <html><head> <script type="text/javascript"> [B]document.getElementById("myForm").onsubmit = function() {[/B] document.getElementById("myDiv").innerHTML = "*** message here ***"; [B]}[/B] </script> </head> <body> <div id="myDiv"></div> <form id="myForm" action="whatever.php" method="POST"> >>> form code here <<< </form> </body> </html> Code (markup):
as you have asked an alternative way to display the text other than the alert mathod.. you can use document.write();