Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asptoday_discuss thread: How to do it?


Message #1 by "Suryadevara" <jaggu2904@r...> on Fri, 7 Jun 2002 13:29:15
Hi all,

Can any one check this file and send me the solution.
It is just a simple html form with some input is taking form user.
i am validating the form and if there are errors iam displaying those and
showing that form but..in the url..it is adding all the field name with 
values...
i don't want to show like that ...i want to show only the form with the 
entered values...
after displaying the alert with error message.....
how to do.....

Thanks


<%@ Language=VBScript %>
<html>
<head>
	<title>NEW USER DETAILS ENTERY</title>
</head>
<body bgcolor="#ffccff">

<SCRIPT LANGUAGE="javaScript">
	
	function ClearForm(frmname)
	{
		for(var i=0; i<frmname.length; i++)
			{
				var FormElement
				FormElement = 
window.document.FrmNew.elements[i];
				FormElement.value ="";
			}	
	}
		
	function checkall(frmname)
	{
		var msg;
		msg 
= "_________________________________________________\n\n"
		msg += "The form was not submitted because of following 
error (s).\n "
		msg += "Please correct the following and Resubmit the 
form. \n\n"
		msg 
+= "_________________________________________________\n\n"
		var EmptyFields="";
		var FE;
		var error="";
		var ev;
		
		for(var i=0; i<frmname.length; i++)
			{
				FE = window.document.FrmNew.elements[i];
				ev = FE.value;
				if ((FE.value == null) ||(FE.value == ""))
				{			
					EmptyFields 
+= "\n           "+FE.name;
				}
				else if ((FE.name == "Phone") && 
((ev.length > 50) || (ev.length < 5)))
				{
				      alert(FE.name);		 	  
				      error = "The value of " + FE.name 
+ " should be numeric or should less than 50 or should be greater than 5";
				}
				
				   
			}
		if ((!EmptyFields == true) && (!error == true))
		{
		 window.document.FrmNew.method="post"; 
		 window.document.FrmNew.action ="ss.asp"; 
		 window.document.FrmNew.submit;
		}
		if ((!EmptyFields) && (!error)) return true;
		
		if (EmptyFields)
		{
			msg += "-The Following Required Field (s) are 
empty:" + EmptyFields +"\n";
		if (error) msg +="\n";
			      						
	
		}  			
		    msg += error
			alert(msg);
			return false;		
				
	}		

</SCRIPT>

<DIV align=left>
<form name="FrmNew">
 
  <div>&nbsp;
    <p>&nbsp;</p>
    <p>&nbsp;&nbsp;&nbsp;</p></div>
 
  <div align=center>
<TABLE border=0 cellPadding=1 cellSpacing=1 style="HEIGHT: 177px" 
width="414">
  
  <TR>
    <TD width="400" colspan="2">
      <h1 align="left"><b><font color="#0000ff" face="Arial 
Narrow">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <i>Enter your Details</i></font></b></h1>
    </TD>
  </TR>
  
  <TR>
    <TD width="154"><b>Username:</b></TD>
    <TD width="246">
  <input name="Username" maxlength="50" ></TD></TR>
  
  <TR>
    <TD width="154"><b>Password:</b></TD>
    <TD width="246">
  <input name="Password" maxlength="50" type="password" ></TD></TR>
  
  <TR>
    <TD width="154"><b>Confirm Password:</b></TD>
    <TD width="246">
  <input name="ConfirmPassword" maxlength="50" type="password" ></TD></TR>
  
  <TR>
    <TD 
width="154"><STRONG>Name:</STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;</TD>
    <TD width="246">
  <input name="Name" maxlength="50" ></TD></TR>
  <TR>
    <TD width="154"><STRONG>Address:</STRONG></TD>
    <TD width="246">
  <input name="Address" maxlength="150" ></TD></TR>
  <TR>
    <TD width="154">
  <p><b>
  Phone:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</b></p></TD>
    <TD width="246">
  <input name="Phone" maxlength="50" > </TD></TR>
  <TR>
    <TD width="154">
  <p><b>
  Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</b></p></TD>
    <TD width="246">
  <input name="Email" maxlength="50" ></TD></TR>
  <TR>
    <TD width="154"><STRONG>Designation:</STRONG>&nbsp;</TD>
    <TD width="246">
  <input name="Designation" style="LEFT: 317px; TOP: 206px" maxlength="50" 
></TD></TR>
  <TR>
    <TD width="154">
  <b>
  Department:&nbsp;</b></TD>
    <TD width="246">
  <input name="Department" maxlength="50" ></TD></TR></TABLE></div>
  <p align="center">
  <br>
 
  <input type="button" value="  Back  " name="back" tabindex="1" 
onclick="javascript:window.history.go(-1);" style="FONT-FAMILY: 
serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="submit" value="  Submit  " name="Submit" onclick="checkall
('newemp')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  <INPUT name="Clear" type="button" value="  Clear  " OnClick="ClearForm
('newemp')"><br>
  
  
</form></P></DIV>

</body>

</html>
Message #2 by Subha Gowri <subha@i...> on Fri, 7 Jun 2002 17:59:27 +0530
specify method="post" in form tag. 

Reason :
Form will take "get" method by default. so all the form values 
shall be sent thru. url to the action page.
If you specify the method as post, all the values will be send thro. message

body not thru. url.


-----Original Message-----
From: Suryadevara [mailto:jaggu2904@r...]
Sent: Friday, June 07, 2002 6:59 PM
To: ASPToday Discuss
Subject: [asptoday_discuss] How to do it?


Hi all,

Can any one check this file and send me the solution.
It is just a simple html form with some input is taking form user.
i am validating the form and if there are errors iam displaying those and
showing that form but..in the url..it is adding all the field name with 
values...
i don't want to show like that ...i want to show only the form with the 
entered values...
after displaying the alert with error message.....
how to do.....

Thanks


<%@ Language=VBScript %>
<html>
<head>
	<title>NEW USER DETAILS ENTERY</title>
</head>
<body bgcolor="#ffccff">

<SCRIPT LANGUAGE="javaScript">
	
	function ClearForm(frmname)
	{
		for(var i=0; i<frmname.length; i++)
			{
				var FormElement
				FormElement = 
window.document.FrmNew.elements[i];
				FormElement.value ="";
			}	
	}
		
	function checkall(frmname)
	{
		var msg;
		msg 
= "_________________________________________________\n\n"
		msg += "The form was not submitted because of following 
error (s).\n "
		msg += "Please correct the following and Resubmit the 
form. \n\n"
		msg 
+= "_________________________________________________\n\n"
		var EmptyFields="";
		var FE;
		var error="";
		var ev;
		
		for(var i=0; i<frmname.length; i++)
			{
				FE = window.document.FrmNew.elements[i];
				ev = FE.value;
				if ((FE.value == null) ||(FE.value == ""))
				{			
					EmptyFields 
+= "\n           "+FE.name;
				}
				else if ((FE.name == "Phone") && 
((ev.length > 50) || (ev.length < 5)))
				{
				      alert(FE.name);		 	  
				      error = "The value of " + FE.name 
+ " should be numeric or should less than 50 or should be greater than 5";
				}
				
				   
			}
		if ((!EmptyFields == true) && (!error == true))
		{
		 window.document.FrmNew.method="post"; 
		 window.document.FrmNew.action ="ss.asp"; 
		 window.document.FrmNew.submit;
		}
		if ((!EmptyFields) && (!error)) return true;
		
		if (EmptyFields)
		{
			msg += "-The Following Required Field (s) are 
empty:" + EmptyFields +"\n";
		if (error) msg +="\n";
			      						
	
		}  			
		    msg += error
			alert(msg);
			return false;		
				
	}		

</SCRIPT>

<DIV align=left>
<form name="FrmNew">
 
  <div>&nbsp;
    <p>&nbsp;</p>
    <p>&nbsp;&nbsp;&nbsp;</p></div>
 
  <div align=center>
<TABLE border=0 cellPadding=1 cellSpacing=1 style="HEIGHT: 177px" 
width="414">
  
  <TR>
    <TD width="400" colspan="2">
      <h1 align="left"><b><font color="#0000ff" face="Arial 
Narrow">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <i>Enter your Details</i></font></b></h1>
    </TD>
  </TR>
  
  <TR>
    <TD width="154"><b>Username:</b></TD>
    <TD width="246">
  <input name="Username" maxlength="50" ></TD></TR>
  
  <TR>
    <TD width="154"><b>Password:</b></TD>
    <TD width="246">
  <input name="Password" maxlength="50" type="password" ></TD></TR>
  
  <TR>
    <TD width="154"><b>Confirm Password:</b></TD>
    <TD width="246">
  <input name="ConfirmPassword" maxlength="50" type="password" ></TD></TR>
  
  <TR>
    <TD 
width="154"><STRONG>Name:</STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;</TD>
    <TD width="246">
  <input name="Name" maxlength="50" ></TD></TR>
  <TR>
    <TD width="154"><STRONG>Address:</STRONG></TD>
    <TD width="246">
  <input name="Address" maxlength="150" ></TD></TR>
  <TR>
    <TD width="154">
  <p><b>
  Phone:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</b></p></TD>
    <TD width="246">
  <input name="Phone" maxlength="50" > </TD></TR>
  <TR>
    <TD width="154">
  <p><b>
  Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</b></p></TD>
    <TD width="246">
  <input name="Email" maxlength="50" ></TD></TR>
  <TR>
    <TD width="154"><STRONG>Designation:</STRONG>&nbsp;</TD>
    <TD width="246">
  <input name="Designation" style="LEFT: 317px; TOP: 206px" maxlength="50" 
></TD></TR>
  <TR>
    <TD width="154">
  <b>
  Department:&nbsp;</b></TD>
    <TD width="246">
  <input name="Department" maxlength="50" ></TD></TR></TABLE></div>
  <p align="center">
  <br>
 
  <input type="button" value="  Back  " name="back" tabindex="1" 
onclick="javascript:window.history.go(-1);" style="FONT-FAMILY: 
serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="submit" value="  Submit  " name="Submit" onclick="checkall
('newemp')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  <INPUT name="Clear" type="button" value="  Clear  " OnClick="ClearForm
('newemp')"><br>
  
  
</form></P></DIV>

</body>

</html>
Message #3 by Senthil Raja V <senthil@s...> on Fri, 07 Jun 2002 19:22:11 +0100
hi!

1. method="post" inside form tag.
2. validation function should return false to onsubmit() or onclick() event 
once invalid entries are found.

rgds
senthil

At 05:59 PM 07/06/2002 +0530, you wrote:

>specify method="post" in form tag.
>
>Reason :
>Form will take "get" method by default. so all the form values
>shall be sent thru. url to the action page.
>If you specify the method as post, all the values will be send thro. message
>
>body not thru. url.
>
>
>-----Original Message-----
>From: Suryadevara [mailto:jaggu2904@r...]
>Sent: Friday, June 07, 2002 6:59 PM
>To: ASPToday Discuss
>Subject: [asptoday_discuss] How to do it?
>
>
>Hi all,
>
>Can any one check this file and send me the solution.
>It is just a simple html form with some input is taking form user.
>i am validating the form and if there are errors iam displaying those and
>showing that form but..in the url..it is adding all the field name with
>values...
>i don't want to show like that ...i want to show only the form with the
>entered values...
>after displaying the alert with error message.....
>how to do.....
>
>Thanks
>
>
><%@ Language=VBScript %>
>
>
>
>
>
>
>
>Enter your Details
>
>
>
>Username:
>Password:
>Confirm Password:
>Name:        ;
>Address:
>
>Phone:
>
>Email:
>Designation:
>Department:
>
>


  Return to Index