Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validation trouble - Please help!!! 1

Status
Not open for further replies.

frogggg

Programmer
Jan 17, 2002
182
US
I am having the hardest time with this validation script!

I tried:
1) Running through the values, and creating a string with all bad values, and if there are any, printing them to the screen. I do not want to do this in an alert. I would like to have a header tag at the top of the reloaded form page, with all filled in textboxes still filled in, and the header tag displaying the string. The string part I got no problem, but the page just displays the header tag, no form. Can someone help? How can I reload the page with the tag on top?

2) Rewriting the entire form, with black labels if correct values, and red ones if incorrect. This works fine. However, if the second time around is still not filled in properly, it submits anyway, because the document.write at the beginning of the line cancels out the onSubmit="chkForm()".

3) Someone here suggested using .innerHTML, which I just discovered doesn't work very well for tables, so instead of parsing the code, it just spits it all out onto the screen.

I would really appreciate some help and direction!

Thanks!
 
innerHTML is used to replace the &quot;inner HTML&quot; of some object on the page. In your case we replace the existing content between the <form> and the </form> tags.

The form is what determines how information is sent to the server. When using the get method to send data to the server, the amount of data that can be sent is limited by the maximum length of a URL. In this case the URL cannot be longer than 2048 bytes
 
But, as far as I can tell, there is no beginning form tag in the script section!
Where should it go?
Thanks again
 
The form tag already exists on the page. You do not need to rewrite it through script.

for example
Say your html page is as follows&quot;
<html>
<head>
</head>
<body>
<form name=&quot;frmTest&quot; action=&quot;nextpage.htm&quot; method=post>
<input type=text name=&quot;txtTest&quot;>
<input type=Submit value=&quot;submit&quot;>
</form>
</body>
</html>

the value of frmTest.innerHTML would be the following
<input type=text name=&quot;txtTest&quot;>
<input type=Submit value=&quot;submit&quot;>

So if thru script I replaced the innerHTML with the following:
frmTest.innerHTML='<input type=&quot;text&quot; name=&quot;txtFirstName&quot;><input type=&quot;Submit&quot; value=&quot;ClickMe&quot;>'

then the HTML page would look like this after I ran the script

<html>
<head>
</head>
<body>
<form name=&quot;frmTest&quot; action=&quot;nextpage.htm&quot; method=post>
<input type=&quot;text&quot; name=&quot;txtFirstName&quot;>
<input type=&quot;Submit&quot; value=&quot;ClickMe&quot;>
</form>
</body>
</html>

So all I did was replace the innerHTML of the form with my new HTML. The action and method of the form remain unchanged(the same as in the original page).
That is exactly what your pages are doing
 
So then why won't the values submit?
I thought maybe there were too many of them, so I switched the get to a post, but it didn't help.
They used to be there in the URL, where are they?
Please Help!!!!
 
Just to check, I just got rid of the onSubmit=&quot;return isReady(this)&quot; and it submitted just fine as a get, in the URL, and I was able to get the values on the next page in the querystring.

Do you know why this would be?
 
I tried the post method and the values are showing up on the next page
 
ON THE FIRST PAGE WE WORKED ON MOVE THE
FOLLOWING STATEMENT document.form1.innerHTML =&quot;&quot;
FROM THE TOP OF THE SCRIPT
INTO THE FOLLOWING LOOP

if (counter > 0)
{
strHtml = strHtml + '<h3><font color=&quot;#ff0000&quot;>The fields in red are required.</font></h3>';
strHtml = strHtml + '<tr><td><INPUT type=&quot;submit&quot; value=&quot;Submit&quot; id=submit2 name=submit2></td></tr>';
strHtml = strHtml + '</table>';
'********************
document.form1.innerHTML = &quot;&quot;;
'**********************
document.form1.innerHTML = strHtml;

return false;
//reset counter
counter = 0;
}
else
{
return true;
}


THAT SHOULD FIX YOUR PROBLEM.
THE SECOND PAGE WE WORKED ON SHOULD WORK
 
Wow! I never would have noticed that!

Many thanks again!!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top