...

View Full Version : Help me find this error



lansing
02-10-2007, 03:47 AM
I am not sure what is wrong with this code, but even if there is an error it still submits the form. It should stop & not submit if the fields are blank, but it is just submitting the blank form.


<script type="text/javascript" language=javascript>
function checkform() {
if (document.easy_memos.question.value=='') {
alert("<?php echo JS_ALERT_USER_TEXT; ?>");
document.easy_memos.question.focus();
return false;
}
return true;
}
</script>


If I put this in the code or php tags then you would have to scroll horizontal to see it all so I just posted it in plain text. This is the form line...
<form name="easy_memos" onSubmit="return checkform()" action="http://localhost/TNPB/admin/help_center_data.php?category=1&page=1&action=insert" method="post">

koyama
02-10-2007, 05:15 AM
I cannot really see what it could be. Maybe you have some double quote echoed by php? Can you show us what you get for the alert()-line when you say View > Page Source in your browser.

Have you looked in the error console in FF?

lansing
02-10-2007, 05:37 PM
I cannot really see what it could be. Maybe you have some double quote echoed by php? Can you show us what you get for the alert()-line when you say View > Page Source in your browser.

Have you looked in the error console in FF?Just a few CSS errors in the error console. This is from the View Source:
<script type="text/javascript" language=javascript>
function checkform() {
if (document.easy_memos.question.value=='') {
alert("Please enter a question!");
document.easy_memos.question.focus();
return false;
}
return true;
}
</script>

Philip M
02-10-2007, 05:51 PM
Is this not the trouble?

<script type="text/javascript" language=javascript>

koyama
02-10-2007, 06:16 PM
Is this not the trouble?

<script type="text/javascript" language=javascript>
That didn't seem to matter.

I tested the script and it was working for me in both FF and IE. It blocked form submission just fine. So the error must be coming from somewhere else.

I'm afraid you'll have to give us a link if you don't get it resolved.

Here is the code I was testing with.


<html>
<head>
<script type="text/javascript" language=javascript>
function checkform() {
if (document.easy_memos.question.value=='') {
alert("Please enter a question!");
document.easy_memos.question.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<form name="easy_memos" onSubmit="return checkform()"
action="http://localhost/TNPB/admin/help_center_data.php?category=1&page=1&action=insert"
method="post">
<input type="text" name="question">
<input type="submit">
</form>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum