Click to See Complete Forum and Search --> : Node problems


gokou
08-28-2003, 02:23 AM
heres the url to url to the page where my problem is: http://www.uogameresources.com/email.php

The script is a form validation. When you hit submit, it validates the form. I had it working with an alert box at first, but now I want to make text appear right below the form, displaying the errors instead of an alert box. I just started learning about nodes, so I have some knowledge of it, but not enough.

I can make the text appear as a paragraph all the way to the bottom of the page, but that's no good. I did it like this.

var p = document.createElement("p");
p.appendChild(document.createTextNode(msg));

I want to beable to do it, using tr and td elements, but I don't know how to mix 2 elements together.

Can anyone help with this?

Fang
08-28-2003, 06:56 AM
Have a look at this (http://forums.webdeveloper.com/showthread.php?s=&threadid=16166) thread

Fang
08-29-2003, 01:43 AM
Don't mix threads, it's very confusing for others.

Do something like:

function ValidateForm() {
// validation stuff
if(!valid) {
ObjRow = document.createElement("TR");
document.getElementById("table1").appendChild(ObjRow);
ObjCell = document.createElement("TD");
ObjCell.innerHTML = msg;
ObjRow.appendChild(ObjCell);
}
else {document.myform.submit();}
}

<form action="GoHere.html" method="post" name="form" onsubmit="ValidateForm(); return false;">
.
.
<table border="1" cellpadding="0" cellspacing="0" summary="">
<tbody id="table1">
<tr><td>error message</td><tr>
</tbody>
</table>

gokou
08-29-2003, 11:11 AM
Thanks. I'll try that.

gokou
08-29-2003, 07:29 PM
It works. This is what it looks like. http://www.uogameresources.com/email.php.

If you put text in all the fields that are required and you don't put an @ character in your email, it will show the email error. I don't like how the email error shows 3 of the same error messages. Do you know why it does that?

Fang
08-30-2003, 02:10 AM
In the function verify(f), this loop for(var i = 0; i < f.length; i++)
checks the form "i" number of times depending on the number of elements in the form.
You only need to check each form element once.