p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

browser_compatibility thread: One more problem


Message #1 by "padmaja jaganmohan" <padmaja.jaganmohan@w...> on Wed, 20 Nov 2002 10:54:26
Hi all,

I used form tag enclosing each form fields to display it in netscape.It 
works fine but there is another problem . I am trying to POST
the values of the form fields to another .asp page , before which I 
validate
the fields .

I used the following javascript statements to submit

document.f2.action="formsample.asp"
document.f2.method="post";
document.f2.submit();

If I include more forms say f3,f4 ... enclosing each form fields , how do I
POST the values of those fields as well ?

Please help . It is an emergency.

Message #2 by Marios Adamantopoulos <mario@t...> on Wed, 20 Nov 2002 11:06:49 -0000
I'm sending a validation example I've done in the past. I hope it helps you
do what you want to do.

The form tag:
<form action="form1.php" method="post" name="register">

The submit button (I use an image instead of a button):
<a href="javascript:runit();"><img src="images/submit.gif" alt="" width="46"
height="19" border="0"></a>

The validation through javascript:
<script language="JavaScript">
<!--
function runit(){
	var go;
	var errorMessage = "Please enter the following:-\n\n";
	var error = false;
	
	if ((document.register.firstname.value=="") ||
(document.register.firstname.value.length < 2)) {
		errorMessage += "Your First Name\n";
		error = true;
	} else{
	}
	if ((document.register.surname.value=="") ||
(document.register.surname.value.length < 2)) {
		errorMessage += "Your Surname\n";
		error = true;
	} else{
	}
	if (document.register.email.value=="") {
		errorMessage += "Your Email\n";
		error = true;
	} else{
		var str=document.register.email.value;
		if(str.indexOf("@") == -1 || str.indexOf(".") == -1){
			errorMessage += "A valid email address\n";
			error = true;
		}else{
		}
	}

	if (document.register.mobile.value=="") {
		errorMessage += "Your Mobile Number\n";
		error = true;
	} else{
		var checkOK = "0123456789";
		var checkStr = document.register.mobile.value;
		var allValid = true;
		for (i = 0;  i < checkStr.length;  i++) {
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
			break;
			if (j == checkOK.length) {
				allValid = false;
				break;
			}
		}
		var third = document.register.mobile.value;
		
		if (!allValid) {
			errorMessage += "Only numeric characters in the
\"Mobile\" field (no spaces)\n";
			register.mobile.focus();
			error = true;
		} else {
			if ((document.register.mobile.value.length < 11) ||
(document.register.mobile.value.length > 11)) {
				errorMessage += "11 Numbers in the
\"Mobile\" field (no spaces)\n";
				error = true;
			} else if (third.substring(0,2) != "07") {
				errorMessage += "A mobile number that starts
with 07 in the \"Mobile\" field.\n";
				error = true;
			} else {
			}
		}
	}	
	if ((document.register.sim.value=="") ||
(document.register.sim.value.length < 2)) {
		errorMessage += "Your SIM number\n";
		error = true;
	} else{
	}
	if(error){
		alert(errorMessage);
	}else{
		document.forms[0].submit();
	}
}
//-->
</script>


_________________________
Marios Adamantopoulos
Senior Developer

Tonic
+44 (0)20 7691 2227
+44 (0)7904 221663
www.tonic.co.uk

Recent projects
www.polydor.co.uk
www.adcecreative.org
www.sony-europe.com/pocketlife
............................................................................
....................................
Opinions, conclusions and other information in this message that do not
relate to the official business of Tonic Design Limited shall be
understood as neither given nor endorsed by them.
............................................................................
....................................


-----Original Message-----
From: padmaja jaganmohan [mailto:padmaja.jaganmohan@w...] 
Sent: 20 November 2002 10:54
To: browser_compatibility
Subject: [browser_compatibility] One more problem


Hi all,

I used form tag enclosing each form fields to display it in netscape.It 
works fine but there is another problem . I am trying to POST the values of
the form fields to another .asp page , before which I 
validate
the fields .

I used the following javascript statements to submit

document.f2.action="formsample.asp"
document.f2.method="post";
document.f2.submit();

If I include more forms say f3,f4 ... enclosing each form fields , how do I
POST the values of those fields as well ?

Please help . It is an emergency.


Message #3 by <pankaj.shinde@i...> on Wed, 20 Nov 2002 16:27:38 +0530
Hi Padmaja,
No need to put each input tag in seperate form tag.

Put all ur input tags under one Form Tag and Submit it...

I hope I got the problem exactly, if not please correct me.

With Regards,
-Pankaj Shinde


-----Original Message-----
From: padmaja jaganmohan [mailto:padmaja.jaganmohan@w...]
Sent: Wednesday, November 20, 2002 4:24 PM
To: browser_compatibility
Subject: [browser_compatibility] One more problem


Hi all,

I used form tag enclosing each form fields to display it in netscape.It
works fine but there is another problem . I am trying to POST
the values of the form fields to another .asp page , before which I
validate
the fields .

I used the following javascript statements to submit

document.f2.action=3D"formsample.asp"
document.f2.method=3D"post";
document.f2.submit();

If I include more forms say f3,f4 ... enclosing each form fields , how 
do I
POST the values of those fields as well ?

Please help . It is an emergency.

Message #4 by Quinton Sheppard <quintons@k...> on Wed, 20 Nov 2002 12:29:30 -0000
There is one miner point that would make this validation code more
efficient. If you apply the following:

var o = document.register

then it would stop the browser from continually looking up for that form
(the register form). So to get a value from say for example an input field
named 'firstname' you would use:

o.firstname.value

Just a suggestion, makes code a little smaller when referencing the same
form many times over.

Quinton.
 -----Original Message-----
From: 	Marios Adamantopoulos [mailto:mario@t...] 
Sent:	20 November 2002 11:07
To:	browser_compatibility
Subject:	[browser_compatibility] RE: One more problem

I'm sending a validation example I've done in the past. I hope it helps you
do what you want to do.

The form tag:
<form action="form1.php" method="post" name="register">

The submit button (I use an image instead of a button):
<a href="javascript:runit();"><img src="images/submit.gif" alt="" width="46"
height="19" border="0"></a>

The validation through javascript:
<script language="JavaScript">
<!--
function runit(){
	var go;
	var errorMessage = "Please enter the following:-\n\n";
	var error = false;
	
	if ((document.register.firstname.value=="") ||
(document.register.firstname.value.length < 2)) {
		errorMessage += "Your First Name\n";
		error = true;
	} else{
	}
	if ((document.register.surname.value=="") ||
(document.register.surname.value.length < 2)) {
		errorMessage += "Your Surname\n";
		error = true;
	} else{
	}
	if (document.register.email.value=="") {
		errorMessage += "Your Email\n";
		error = true;
	} else{
		var str=document.register.email.value;
		if(str.indexOf("@") == -1 || str.indexOf(".") == -1){
			errorMessage += "A valid email address\n";
			error = true;
		}else{
		}
	}

	if (document.register.mobile.value=="") {
		errorMessage += "Your Mobile Number\n";
		error = true;
	} else{
		var checkOK = "0123456789";
		var checkStr = document.register.mobile.value;
		var allValid = true;
		for (i = 0;  i < checkStr.length;  i++) {
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
			break;
			if (j == checkOK.length) {
				allValid = false;
				break;
			}
		}
		var third = document.register.mobile.value;
		
		if (!allValid) {
			errorMessage += "Only numeric characters in the
\"Mobile\" field (no spaces)\n";
			register.mobile.focus();
			error = true;
		} else {
			if ((document.register.mobile.value.length < 11) ||
(document.register.mobile.value.length > 11)) {
				errorMessage += "11 Numbers in the
\"Mobile\" field (no spaces)\n";
				error = true;
			} else if (third.substring(0,2) != "07") {
				errorMessage += "A mobile number that starts
with 07 in the \"Mobile\" field.\n";
				error = true;
			} else {
			}
		}
	}	
	if ((document.register.sim.value=="") ||
(document.register.sim.value.length < 2)) {
		errorMessage += "Your SIM number\n";
		error = true;
	} else{
	}
	if(error){
		alert(errorMessage);
	}else{
		document.forms[0].submit();
	}
}
//-->
</script>


_________________________
Marios Adamantopoulos
Senior Developer

Tonic
+44 (0)20 7691 2227
+44 (0)7904 221663
www.tonic.co.uk

Recent projects
www.polydor.co.uk
www.adcecreative.org
www.sony-europe.com/pocketlife
............................................................................
....................................
Opinions, conclusions and other information in this message that do not
relate to the official business of Tonic Design Limited shall be
understood as neither given nor endorsed by them.
............................................................................
....................................


-----Original Message-----
From: padmaja jaganmohan [mailto:padmaja.jaganmohan@w...] 
Sent: 20 November 2002 10:54
To: browser_compatibility
Subject: [browser_compatibility] One more problem


Hi all,

I used form tag enclosing each form fields to display it in netscape.It 
works fine but there is another problem . I am trying to POST the values of
the form fields to another .asp page , before which I 
validate
the fields .

I used the following javascript statements to submit

document.f2.action="formsample.asp"
document.f2.method="post";
document.f2.submit();

If I include more forms say f3,f4 ... enclosing each form fields , how do I
POST the values of those fields as well ?

Please help . It is an emergency.





Confidentiality:  This e-mail and its attachments are intended for the above
named only and may be confidential.  If they have come to you in error you
must take no action based on them, nor must you copy or show them to anyone;
please reply to this e-mail and highlight the error. 

Security Warning:  Please note that this e-mail has been created in the
knowledge that Internet e-mail is not a 100% secure communications medium.
We advise that you understand and observe this lack of security when
e-mailing us. 

Viruses:  Although we have taken steps to ensure that this e-mail and
attachments are free from any virus, we advise that in keeping with good
computing practice the recipient should ensure they are actually virus free.


Message #5 by "padmaja" <padmaja.jaganmohan@w...> on Wed, 20 Nov 2002 16:56:10 +0530
Thanx ,
I'll try that.

-----Original Message-----
From: Quinton Sheppard [mailto:quintons@k...]
Sent: Wednesday, November 20, 2002 6:00 PM
To: browser_compatibility
Subject: [browser_compatibility] RE: One more problem


There is one miner point that would make this validation code more
efficient. If you apply the following:

var o = document.register

then it would stop the browser from continually looking up for that form
(the register form). So to get a value from say for example an input field
named 'firstname' you would use:

o.firstname.value

Just a suggestion, makes code a little smaller when referencing the same
form many times over.

Quinton.
 -----Original Message-----
From: 	Marios Adamantopoulos [mailto:mario@t...]
Sent:	20 November 2002 11:07
To:	browser_compatibility
Subject:	[browser_compatibility] RE: One more problem

I'm sending a validation example I've done in the past. I hope it helps you
do what you want to do.

The form tag:
<form action="form1.php" method="post" name="register">

The submit button (I use an image instead of a button):
<a href="javascript:runit();"><img src="images/submit.gif" alt="" width="46"
height="19" border="0"></a>

The validation through javascript:
<script language="JavaScript">
<!--
function runit(){
	var go;
	var errorMessage = "Please enter the following:-\n\n";
	var error = false;

	if ((document.register.firstname.value=="") ||
(document.register.firstname.value.length < 2)) {
		errorMessage += "Your First Name\n";
		error = true;
	} else{
	}
	if ((document.register.surname.value=="") ||
(document.register.surname.value.length < 2)) {
		errorMessage += "Your Surname\n";
		error = true;
	} else{
	}
	if (document.register.email.value=="") {
		errorMessage += "Your Email\n";
		error = true;
	} else{
		var str=document.register.email.value;
		if(str.indexOf("@") == -1 || str.indexOf(".") == -1){
			errorMessage += "A valid email address\n";
			error = true;
		}else{
		}
	}

	if (document.register.mobile.value=="") {
		errorMessage += "Your Mobile Number\n";
		error = true;
	} else{
		var checkOK = "0123456789";
		var checkStr = document.register.mobile.value;
		var allValid = true;
		for (i = 0;  i < checkStr.length;  i++) {
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
			break;
			if (j == checkOK.length) {
				allValid = false;
				break;
			}
		}
		var third = document.register.mobile.value;

		if (!allValid) {
			errorMessage += "Only numeric characters in the
\"Mobile\" field (no spaces)\n";
			register.mobile.focus();
			error = true;
		} else {
			if ((document.register.mobile.value.length < 11) ||
(document.register.mobile.value.length > 11)) {
				errorMessage += "11 Numbers in the
\"Mobile\" field (no spaces)\n";
				error = true;
			} else if (third.substring(0,2) != "07") {
				errorMessage += "A mobile number that starts
with 07 in the \"Mobile\" field.\n";
				error = true;
			} else {
			}
		}
	}
	if ((document.register.sim.value=="") ||
(document.register.sim.value.length < 2)) {
		errorMessage += "Your SIM number\n";
		error = true;
	} else{
	}
	if(error){
		alert(errorMessage);
	}else{
		document.forms[0].submit();
	}
}
//-->
</script>


_________________________
Marios Adamantopoulos
Senior Developer

Tonic
+44 (0)20 7691 2227
+44 (0)7904 221663
www.tonic.co.uk

Recent projects
www.polydor.co.uk
www.adcecreative.org
www.sony-europe.com/pocketlife
............................................................................
....................................
Opinions, conclusions and other information in this message that do not
relate to the official business of Tonic Design Limited shall be
understood as neither given nor endorsed by them.
............................................................................
....................................


-----Original Message-----
From: padmaja jaganmohan [mailto:padmaja.jaganmohan@w...]
Sent: 20 November 2002 10:54
To: browser_compatibility
Subject: [browser_compatibility] One more problem


Hi all,

I used form tag enclosing each form fields to display it in netscape.It
works fine but there is another problem . I am trying to POST the values of
the form fields to another .asp page , before which I
validate
the fields .

I used the following javascript statements to submit

document.f2.action="formsample.asp"
document.f2.method="post";
document.f2.submit();

If I include more forms say f3,f4 ... enclosing each form fields , how do I
POST the values of those fields as well ?

Please help . It is an emergency.





Confidentiality:  This e-mail and its attachments are intended for the above
named only and may be confidential.  If they have come to you in error you
must take no action based on them, nor must you copy or show them to anyone;
please reply to this e-mail and highlight the error.

Security Warning:  Please note that this e-mail has been created in the
knowledge that Internet e-mail is not a 100% secure communications medium.
We advise that you understand and observe this lack of security when
e-mailing us.

Viruses:  Although we have taken steps to ensure that this e-mail and
attachments are free from any virus, we advise that in keeping with good
computing practice the recipient should ensure they are actually virus free.






  Return to Index