View Full Version : Redirecting to new URL after form validated and submitted

02-24-2007, 05:11 AM
Hello I'm looking for the code for Redirecting to new URL after form validated and submitted

When I put OnSubmit go to URL, the form is not validated and is not submited to my email...

What can I do? right now I have this code that validates and submits this form correctly:

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

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');

and then:

<form action="mailto:press@avilajet.com" method="post" name="form1" onSubmit="MM_validateForm('Apelido/Nome','','R','Tel Trabalho','','R','Telem&oacute;vel','','R','E-mail','','R','Morada','','R','localidade1','','R','Titulo meio','','R','Morada meio','','R','localidade2','','R');return document.MM_returnValue">

what can I do to make it also go to a new URL after validating and submitting correctly?

my email: elsasantoscosta@gmail.com

02-24-2007, 03:53 PM

my email: elsasantoscosta@gmail.com

02-25-2007, 11:20 PM
Can anybody help me please?? I've tried everyhing REAL!!!

I read tutorials, went to other forums...everything...is there a roundabout to this problem?

02-25-2007, 11:52 PM
You should use PHP instead of the action="mailto:press@avilajet.com" as that will open the defult mail client, and is anoying, does your server have it?

<input type="submit" value="Submit" name="B1" onclick="location.href='http://www.google.com'">

However that will not valadate first so why not add in the valadate js else (no errors) location.href??

02-26-2007, 10:41 PM
you were saying that in the validation script I shoud put a code that if there was no errors it would go to the uRL..

Yes that should do it!

Can you give me the code?
Where do I put it?
I'm kind of new with javascript...

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum