Link to home
Start Free TrialLog in
Avatar of kate2001
kate2001

asked on

how to carry an error message and pass it to the previous page

Dear experts,

I am trying to validate my email form that has been written using html tag.
i.e. the form is saved in contact.html and
the validater and functinality that used to send out an email is saved in sendemail.asp page.

What I want is, when ever the user try to send out an email with out filling his/her first name or sencond name, I want my form to redrect back to contact.htm page with an error message telling them that one of the field is not filled our.

Is it possible to append  an error message with the redirect function?
If so, how do I append a message?


' validation
Dim validationOK
validationOK=true
If (Trim(First)="") Then validationOK=false
If (Trim(Last)="") Then validationOK=false
If (Trim(Company)="") Then validationOK=false
If (validationOK=false) Then Response.Redirect("contact_support.html" & EmailFrom)
'Response.Write "Please fill out the requered fields: <b>" & EmailForm & "</b>"



Thank you inadvance
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

No, you can't send any info like that to an HTML page.  It will be ignored..  You could clone your "contact.html" as "contact.asp" and use ASP to put up the error message.  A more common way is to make the "contact.asp" as a self-contained page that posts to itself.  That way, you will have the data so you can put up error messages along with the original data or simply say 'Thanks' and send the email when they do it correctly.
ASKER CERTIFIED SOLUTION
Avatar of Cedric Obinna A.
Cedric Obinna A.
Flag of Nigeria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kate2001
kate2001

ASKER

Dear Cedlinx,

I feel like it would work this way. I can't wait till I try your solution. I will let you know the result.

Thank you so much!
What is wrong with my validation check? I couldnt get the error message when I leave "Last" name empty.
<form method="POST" action="sendmail.asp" id="myform">
<p><i>Fields marked (*) are required</i></p>
<fieldset style=" border-color:#FFFFFF">
<legend> <p><b>My Contact Form</b></p></legend>
<br/>
<table border="0">
<tr>
<td><p>Full Name:*</p> </td>
<td> <input type="text" name="Last" size="35"  ></td>
</tr>
<tr>
<td><p>Company:*</p></td>
<td> <input type="text" name="Company" size="35" ></td>
</tr>
<tr>
<td><p>Email:*</p> </td>
<td><input type="text" name="Email" size="35" ></td>
</tr>
<tr>
<td><p>Telephone:* </p></td>
<td> <input type="text" name="Telephone" size="35" > </td>
</tr>

<tr>
<td><p>User ID:</p> </td>
<td> <input type="text" name="Userid"  size="35" > </td>
</tr>
<tr>
<td><p>Project Owner:</p> </td>
<td> <input type="text" name="Projectowner"  size="35" > </td>
</tr>
</table>
</fieldset>
<fieldset style=" border-color:#FFFFFF" >
<legend> <p><b>Questions</b></p> </legend>
<table border="0">
<tr>
<td><p>Message:</p></td>
</tr>
<tr>
<td><textarea rows="10" cols="62%" name="Message"  >
</textarea></td>
</tr>
</table>

<p><center><input type="submit" name="submit" value="Submit"></center></p>
</fieldset>
</form>
<script Language="JavaScript" Type="text/javascript">
function FrontPage_Form1_Validator(myform)
{
 
 if (myform.Last.value == "")
  {
    alert("Please enter a value for the \"Username\" field.");
    myform.Last.focus();
    return (false);
  }}
</script>

Open in new window

And all the code above is inside <body> tag. What am I missing? And how can I get the the validation check before the form is sending an email (going to sendemail.asp) page?




Thank you inadvance
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect!

Thank you cedlinx and DaveBaldwin!!!