Total members 11894 |It is currently Sun Nov 24, 2024 5:13 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Here an html and javascript form , you can put it in your site to allow users to send mails to using this form and they can decide their topic and part ,you should action the form to any dynamic script like php to send mail .
html code
 <script language="javascript" type="text/javascript">
    function validateForm()
    {
            document.getElementById('errorDiv').innerHTML="";        
            var errorDiv = document.getElementById('errorDiv');
            var email = document.getElementById('email').value;
            var name = document.getElementById('name').value;
            var comment = document.getElementById('comment').value;
            var feedbackTypeindex = document.getElementById('FeedbackType').selectedIndex;                        
            var subject = document.getElementById('subject').value;            
            apos=email .indexOf("@");
            dotpos=email .lastIndexOf(".");
            var errorDiv = document.getElementById('errorDiv');

        if(feedbackTypeindex == 0)
        {
            //alert("Please select feedback type");
            //document.getElementById('errorDiv').innerHTML="<li><font color='red'>Please select feedback type</font></li>";
            errorDiv.innerHTML = "<li><font color='red'>Please select feedback type</font></li>";
            return false ;
        }
        
        if(name== null || name=="")
        {
            //alert("Please enter your name");
            errorDiv.innerHTML = "<li><font color='red'>Please enter your name</font></li>";
            return false;
        }
        
        if(email == null || email =="")
        {
            //alert("Please enter email address");
            errorDiv.innerHTML = "<li><font color='red'>Please enter email address</font></li>";
            return false;
        }
        else if (apos<1||dotpos-apos<2) 
        {
            //alert("Please enter valid email address, ie.:[email protected]");
            errorDiv.innerHTML = "<li><font color='red'>Please enter valid email address, ie.:[email protected]</font></li>";
            return false;
        }
        
        
        
        
        if(subject == null || subject=="")
        {
            //alert("Please enter the subject");
            errorDiv.innerHTML = "<li><font color='red'>Please enter the subject</font></li>";
            return false;
        }
        
        if(comment== null || comment=="")
        {
            //alert("Please enter the message");
            errorDiv.innerHTML = "<li><font color='red'>Please enter the message</font></li>";
            return false;
        }        
    }
    </script>
 
   <div class="content" >
 
<div>
<table border="0">
<form name="contacts" action="<?=$HOST?>Services/mail.php" method="post" onSubmit="return validateForm();">
<tr><td colspan="2">
feedback type</td><td><select name="FeedbackType" id="FeedbackType">
<option value="0">- select -</option> 
<option value="Sponsership">sponsorship</option>

<option value="ads">Advertise</option> 
<option value="others">Others</option> 
</select></td></tr>
<tr><td colspan="2">
name</td><td><input type="text" name="name" id="name" value="" maxlength="30" /></td></tr>
<tr><td colspan="2">
email</td><td><input type="text" name="email" id="email" value="" maxlength="30" />&nbsp;example: [email protected]</td></tr>
<tr><td colspan="2">
subject</td><td><input type="text" name="subject" id="subject" value="" maxlength="30" /></td></tr>
<tr><td colspan="2">
comments</td><td><textarea name="comment" id="comment" rows="5" cols="30"></textarea></td></tr>
<tr><td colspan="2"></td><td><input type="submit" value="send" style="width:100px"  /></td></tr>
</form>
<tr><div id="errorDiv" name="errorDiv" style="margin-left:15px;" ></div> </tr>
</table>
</div>
</div>





Attachments:
File comment: form screenshot ,
form.GIF
form.GIF [ 5.33 KiB | Viewed 7449 times ]

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada
Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : cotact us html and javascript form
 HTML Form i made     -  
 HTML registration form example     -  
 PHP HTML form with to file upload     -  
 getting gst, pst total to diplay in my javascript form     -  
 Javascript Form Calculation Error :banghead:     -  
 form-Radio-buttons-checkBoxs-actions-HTML-Tags     -  
 I'm having a problem creating a Javascript form. Whats wrong     -  
 How to use HTML with JavaScript     -  
 Hide HTML Div using JavaScript     -  
 php login form (sign-in form)     -  



Topic Tags

JavaScript Validation, HTML Form
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com