Click to See Complete Forum and Search --> : help - simple problem please....


hyde11
03-12-2003, 11:36 PM
This is driving me nuts; I am having trouble with the following simple script:

function checkform()
{
var check = this.document.Workplan;
if ((check.request.value=="") || (check.cash.value=="") || (check.inkind.value==""))
{
alert("Please enter all required fields.");
check.request.focus();
return false;
}
check.submit();
}

It says "object does not support this property or method" referring to the "check.submit();" line. Why not? I can get the form to submit without validation (using a submit button)...

The form is named "Workplan" (case matches), has proper start and end tags?

Thoughts? Thanks so much for your help.

khalidali63
03-12-2003, 11:41 PM
How about losing the this statement before document.?


Khalid

Jona
03-12-2003, 11:42 PM
OK well first I'd have to say that's not exactly the best security on your script. They could just enter a space and it would work. Anyways let's see about this line:

var check = document.Workplan

You don't, I don't think, have to have the "this" in there.
Other than that, you need to put else in there like this:

if ((check.request.value=="") || (check.cash.value=="") || (check.inkind.value=="")) {
alert("Please enter all required fields.");
check.request.focus();
return false;
} else {check.submit();}

See what I mean?

hyde11
03-12-2003, 11:49 PM
I tried both suggestions, but to no avail....I have another script to check for numbers, and strip out other characters onblur.

The script is contain in a cold fusion template that is "included" by a call from another template - would that make a difference? I have checked to make sure all tags are balanced...note, I have the script working on other templates. It is very puzzling.

Here is what it looks like now....still same message....

function checkform()
{
var check = document.Workplan;
if ((check.request.value=="") || (check.cash.value=="") || (check.inkind.value==""))
{
alert("Please enter all required fields.");
check.request.focus();
return false;
}
else
{
check.submit();
}
}

Jona
03-12-2003, 11:58 PM
Just a wild idea. I've got a headache and I'm headed off to bed but... try testing it without the "return false" part on there. Just to see what it does.

Nedals
03-13-2003, 12:09 AM
function checkform() {
var check = document.Workplan; // take out THIS
if ((check.request.value=="") || (check.cash.value=="") || (check.inkind.value=="")) {
alert("Please enter all required fields.");
check.request.focus();
return false;
} else { return true }

In your form tag...
<from name="Workplan" action="........." onSubmit="return checkform()">

khalidali63
03-13-2003, 12:18 AM
Ok..here it is.

<script type="text/javascript">
function Process(){
checkform();
}
function checkform(){
var check = document.Workplan;
alert(check.name)
if ((check.request.value=="") || (check.cash.value=="") || (check.inkind.value=="")){
alert("Please enter all required fields.");
check.request.focus();
return false;
}
check.submit();
}
</script>
</head>
<body>
<form name="Workplan" action="somepage.html" onsubmit="">
<input type="Text" name="request"/>
<input type="Text" name="cash"/>
<input type="Text" name="inkind"/>
<input type="Button" value="process" onclick="Process()"/>
</form>
</body>
</html>



I have tested above wiht NS6+ and IE6+

It works for me....there is something in your code which is not shown in the post that is causing the error

Cheers

Khalid