Can't get form action to execute with onsubmit

M

M.L.

Hello. I created a form using JS validation with the form tag as
follows:

<form name="form1" action="dynaform.php" method="post" onsubmit="return
pvg_sub();">

The js validation script sends alerts when fields are not entered
properly and it seems to work, except...when there are no errors,
instead executing the php action script, I get a popup dialog box in IE6
asking if I want to download or run the php script. Can anyone tell me
why the php script is not executing? Thanks.
 
X

xieyanfu

Hello. I created a form using JS validation with the form tag as
follows:

<form name="form1" action="dynaform.php" method="post" onsubmit="return
pvg_sub();">

The js validation script sends alerts when fields are not entered
properly and it seems to work, except...when there are no errors,
instead executing the php action script, I get a popup dialog box in IE6
asking if I want to download or run the php script. Can anyone tell me
why the php script is not executing? Thanks.


your server can't execute php script , you must configure it with
php ?
http://www.php.net for more info .
 
P

prince

Hello. I created a form using JS validation with the form tag as
follows:

<form name="form1" action="dynaform.php" method="post" onsubmit="return
pvg_sub();">

The js validation script sends alerts when fields are not entered
properly and it seems to work, except...when there are no errors,
instead executing the php action script, I get a popup dialog box in IE6
asking if I want to download or run the php script. Can anyone tell me
why the php script is not executing? Thanks.

Did you check the content type field returned by your script?
 
M

M.L.

Hello. I created a form using JS validation with the form tag as
your server can't execute php script , you must configure it with
php ?
http://www.php.net for more info .

Thanks for your reply. I found the dynaform.php script on the Internet
and it worked just fine without the onsubmit javascriptng. Each script
works fine alone; but the dynaform.php script won't launch after the js
is processed.
 
M

M.L.

Did you check the content type field returned by your script?

I don't know PHP. The only header programming I found in the script was
one to send a thank_you.html page or an error.html page. I don't know if
any of the following code will help:

*****************************
// CHECK FOR REQUIRED FIELDS IF ACTIVATED
if($required_on == "yes") {
$sub = substr($incoming_fields[$i], 0, 2);
if($sub == "r_") {
if($incoming_values[$i] == "" OR !isset($incoming_values[$i]) OR
$incoming_values[$i] == " ") {
header("Location: $required_errorpage");
exit();
}}}
*****************************
// FORWARD TO THANK YOU PAGE
header("Location: $incoming_thanks");
*****************************
// MAKE SURE DYNAFORM IS NOT BEING LOADED FROM THE URL
if($_SERVER['REQUEST_METHOD'] == "GET") {
echo "
<html>
<head><title>Webligo PHP DynaForm is installed correctly.</title></head>
<body>
<font style='font-family: verdana, arial; font-size: 9pt;'>
<b>DynaForm is installed correctly.</b></font><br>
<font style='font-family: verdana, arial; font-size: 8pt;'>
DynaForm Easy PHP Form Mailer was created by <a
href='http://www.webligo.com'>Webligo Developments</a>.
</font>
</body></html>
";
exit();
}
*****************************
 
T

Tim Williams

What values does pvg_sub() return ?
If you want the form to submit it should return true.

Tim
 
M

M.L.

Hello. I created a form using JS validation with the form tag as
What values does pvg_sub() return ?
If you want the form to submit it should return true.

Tim

Thanks for responding. All the subs return true unless previously set to
false, I think. The external js form validation code is below. I got
this script off a website too:
***********************************************
<!--
var b = 0 ;
var i = 0 ;
var errmsg = "" ;
var punct = "" ;
var min = 0 ;
var max = 0 ;

function pvg_email(field) {

if (b && (field.value.length == 0)) return true ;


if (! emailCheck(field.value))
{
field.focus();
if (field.type == "text") field.select();
return false ;
}

return true ;
}

function pvg_filledin(field) {

if (b && (field.value.length == 0)) return true;

if (field.value.length < min) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false ;
}

if ((max > 0) && (field.value.length > max)) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false ;
}

return true ;
}

function pvg_number(field) {

if (b && (field.value.length == 0)) return true ; ;

if (i)
var valid = "0123456789"
else
var valid = ".,0123456789"

var pass = 1;
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") pass = 0;

}

if (!pass) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
}

if (field.value < min) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
}


if ((max > 0) && (field.value > max)) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
}

return true ;
}


function pvg_numseq(field) {


if (b && (field.value.length == 0)) return true ;

var valid = punct + "0123456789"

var pass = 1;
var digits = 0
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") pass = 0;
if (valid.indexOf(temp) > (punct.length-1) ) digits++ ;

}

if (!pass) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false ; ;
}

if (digits < min) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
}

if ((max > 0) && (digits > max)) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
}

return true ;
}

function emailCheck (emailStr) {

var checkTLD=1;
var
knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|ws)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);

if (matchArray==null) {
alert(errmsg);
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert(errmsg);
return false;
}
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert(errmsg);
return false;
}
}

if (user.match(userPat)==null) {
alert(errmsg);
return false;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr.search(atomPat)==-1) {
alert(errmsg);
return false;
}
}

if (checkTLD && domArr[domArr.length-1].length!=2 &&
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert(errmsg);
return false;
}

if (len<2) {
alert(errmsg);
return false;
}

return true;
}

function pvg_sub()
{
b=0;
errmsg="Invalid email address";
if (! pvg_email(document.form1.r_Email) ) return false ;
b=0;
errmsg="First name must be filled in.";
min=2;
max=60;
if (! pvg_filledin(document.form1.r_Firstname) ) return false ;
b=0;
errmsg="Last name must be filled in.";
min=2;
max=60;
if (! pvg_filledin(document.form1.r_Lastname) ) return false ;
}
// -->
 
L

Lee

M.L. said:
Thanks for your reply. I found the dynaform.php script on the Internet
and it worked just fine without the onsubmit javascriptng. Each script
works fine alone; but the dynaform.php script won't launch after the js
is processed.

That doesn't really make sense. You won't see any indication of the PHP
file trying to execute unless the onsubmit() has worked correctly.
The PHP code will be loaded into a new page, so nothing in the Javascript
on the previous page can prevent it from loading.

Verify that the php page loads if you don't define any onsubmit handler
at all.


--
 
M

M.L.

Hello. I created a form using JS validation with the form tag as
That doesn't really make sense. You won't see any indication of the
PHP file trying to execute unless the onsubmit() has worked correctly.
The PHP code will be loaded into a new page, so nothing in the
Javascript on the previous page can prevent it from loading.

Verify that the php page loads if you don't define any onsubmit
handler at all.

No, it doesn't make any sense. I loaded the file into a file compare app
and found that I was missing a closing </FORM> tag in my HTML.
Everything works fine now. Thanks to all who replied.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top