SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need a form that will take user input and then email it. It should then redirect the user to a download or(page)after clicking submit. With controls to Clearform and Submit. It must also know that the fields are valid.

  2. #2
    SitePoint Addict
    Join Date
    Oct 2000
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Most properly, this should be done via server-side scripting, rather than client-side.

    Although you can call the email client (e.g., with simple mailto: links) from JavaScript or HTML or a combination thereof, a number of email clients (notably some versions of Outlook (Outlook Express's Office big brother)), that are balky or uncooperative on inclusionary fields for the subject line or the body of the email, and hence unreliable.

    Via a Perl or PHP script, however, this is relatively straightforward. There are a couple of good boilerplate scripts for this (free) at http://www.codebrain.com/perl -- and many, many such scripts freely available at sites like http://www.hotscripts.com , http://www.freeperlcode.com , and others.

  3. #3
    SitePoint Member
    Join Date
    Sep 2000
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, what you want is a keyboard full

    For Validation:

    This is not difficult, as there are many Javascripts out there that can validate form input to make sure what it is before the page information is passed to the server.

    The way you call this Validation you must have this javascript call in your form tag: onSubmit="return function()"

    So when your form has the submit button clicked the onSubmit will call your javascript function to validate your form inputs.

    ie.
    <form action="this" method="post" onSubmit="return ValidateForm()"

    for some validation scripts I would suggest going to:
    javascript.internet.com

    Next is the emailing of your information, this can be done by using this type of method with your form:

    <form ...no action...>
    ....blahblha
    <input type='button' onClick='sendForm(this.form)'>
    </form>

    function sendForm(formObj)
    {
    var emailAdd = formObj.email.value;
    formObj.action = 'mailto:' + emailAdd;
    formObj.submit();
    }

    and that will send your email.

    To redirect your user, this is simple enough, after you have the form information sent via email, you then do a window.location='href'; javascript call to the url you wish to send your client.

    So lets see if I can put all this code together

    function trinary(formObj)
    {

    Validation goes here,
    if false return false, and if true continue to the next step. So the best way to do this is by a if statement.

    if ( info == valide)
    {
    var emailAdd = formObj.email.value;
    formObj.action = 'mailto:' + emailAdd;
    formObj.submit();
    window.location='next';
    }
    else
    {
    window.alert("Please fix your input");
    return false;
    }

    }

    This is just a rough code, if you have any questions just ask, I will answer my babble for you

  4. #4
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Cynthia & welcome to the forum that likes marine life

    etLux is correct regarding his comments about sending data through mailto, especially the Outlook comments

    If you would like to see an example of a form validation script, see the "Validating Forms" script/tutorial at my site. It checks all 'types' (text, select, etc) of field elements for user non-usage. (You should be able to modify it and add any specific tests easily.)

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  5. #5
    SitePoint Addict
    Join Date
    Oct 2000
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a very simple "boilerplate" example of validating fields, just to get you started. Change the conditionals as needed, of course -- this just checks for empty fields.

    <script Language="JavaScript">
    function CheckForm(George){
    if (George.TextA.value == ""){
    alert("Enter text in Text Box A...");
    George.TextA.focus();
    return (false);
    }
    if (George.TextB.value == ""){
    alert("Enter text in Text Box B...");
    George.TextB.focus();
    return (false);
    }
    if (George.TextC.value == ""){
    alert("Enter text in Text Box C...");
    George.TextC.focus();
    return (false);
    }
    return (true);
    }
    </script>
    <form method="POST" onsubmit="return CheckForm(this)" name="George">
    Text Box A<br>
    <input type="text" name="TextA" size="20">
    <br>
    Text Box B<br>
    <input type="text" name="TextB" size="20">
    <br>
    Text Box C<br>
    <input type="text" name="TextC" size="20">
    <br>
    <br>
    <input type="submit" value="Submit" name="sub">
    </form>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •