Note that there are some explanatory texts on larger screens.

plurals
  1. POSend email with ASP but first use external JS file to validate form fields
    primarykey
    data
    text
    <p>As you can probably tell by the title, I'm not sure the best way to phrase this question but here goes.</p> <p>I currently have a basic html page (default.html) with a form, three input fields (name, email, newmessage), and a submit button. The user clicks the submit button which calls emailmessage.asp using the action attribute of the form tag.</p> <pre><code>&lt;form method="post" action="emailmessage.asp"&gt; &lt;table&gt; &lt;tr&gt; &lt;td align="right"&gt;Name:&lt;/td&gt; &lt;td&gt;&lt;input name="name" type="text" value="Type your name here" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt;Email:&lt;/td&gt; &lt;td&gt;&lt;input name="email" type="text" value="Type your email here" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right" valign="top"&gt;Comments:&lt;/td&gt; &lt;td&gt;&lt;textarea name="comments" cols="40" rows="6"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input name="Submit1" type="submit" value="Send Email" /&gt; &lt;input name="Reset1" type="reset" value="Clear Fields" /&gt; &lt;/form&gt; </code></pre> <p>My emailmessage.asp code is as follows:</p> <pre><code>Dim strEmail, strComments Set myMail=CreateObject("CDO.Message") myMail.Subject="Questions and Comments" myMail.From=Request.Form("email") myMail.To=Request.Form("noname@hotmail.com") myMail.TextBody=Request.Form("newmessage") myMail.Send set myMail=nothing </code></pre> <p>Ok, this works, however, I would like to use an external JavaScript file to perform client-side validation when the user clicks the submit button. If all is well, the Javascript file would then call the emailmessage.asp file. Finally, when the email is sent, I would like to redirect to a basic html confirmation page.</p> <p>I guess my question is not only about code but also best process or logic to carry this task out. Any recommendations for how I might do this would be greatly appreciated.</p> <p>Thanks M</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload