Close Panel

LightForm is a free Ajax/PHP contact form. It combines FormCheck2 for fields validation and NiceForms to style text fields and textareas.

Demo:

View Demo »

lightformpreview.jpg

Download:

Use of this contact form is free of charge but the copyright notes in the footer must remain intact.
I would appreciate if you send me the URI of your site if you use LightForm.

Download (373.4 KiB, 8,502 hits)

Updates:

May 28, 2008: Textarea bug fixed.

Features:

  • Form Validation using FormCheck2.
  • Spam Check.
  • Display user IP, user agent and referrer in the message.
  • Display a dialog box when message sent succesfully.
  • Inputs and textareas are styled with NiceForms.
  • Works in the most recent browsers (IE6+, Firefox, Opera, Safari and Netscape).

Installation:

  1. Download and unzip the file
  2. Copy all the files to your root Directory

Usage:

Open index.php in your web editor (e.g. Notepad) and change the email address line 55:
$to = 'yourname@domain.com';

License:

The CSS, XHTML, PHP and design is released under Creative Commons Attribution v2.5.

FormCheck2 is released under the MIT license.

NiceForms is released under no specific license. You are free to use and modify but you must provide credits to the author.

Caution

Form validation won’t work anymore if users disable Javascript.

Popularity: 44% [?]

 

Related posts

| Subscribe to Feed | Email the author

77 Responses to “LightForm ::: Free Ajax/PHP Contact Form”

  1. 1
    Moo Floor » FormCheck v. 1.3 Says:

    [...] A new default theme is avalaible (thanks to Jeremie!) [...]

  2. 2
    zack Says:

    Great. It works smoothly.Firebug detects a slight error on the congrats page though:obj has no properties while (obj.offsetParent) {on line190 of niceforms.jsKeep up the good work.

  3. 3
    dora Says:

    It looks beautiful!Good work!I’ve translated it a little to Simple Chinese.You can visit it here.

  4. 4
    artico Says:

    Hi there, i got a question about this form…How I can change the question and of course the answer of the part “are you human?” I really don’t know much of javascript.I appreciate any help, thanks.

  5. 5
    Jeeremie Says:

    Artico,

    open index.php in a web editor and go to line 152 and change the text:
    <label for="spamcheck"><span class="blue">*</span> <acronym title="[ Spam prevention ]“><strong>Are you human?</acronym> : <span class=”blue”>2 + 3 = ???</span></strong></label>

    To change the answer, open /js/formcheck/formcheck.js and go to line 155:
    spamcheck : /^[5]+$/,
    … and change number 5 for another number.

    You must also change the question line 136 to match your answer:
    spamcheck : "2 + 3 = ???

    Let me know if you could do it.

  6. 6
    artico Says:

    Hi Jeeremie, that was easy to change, thanks for your help.

  7. 7
    paco Says:

    I wanted to know how could I add some radio and checkboxs to my form, because they don’t appear…Thank a lot!

  8. 8
    Jeeremie Says:

    It is normal Paco, I didn’t create radio and checkboxes images for this form. If you really need some for your form, go to Badboy.ro and download his form to get the images.

    I hope it helps.

  9. 9
    Paco Says:

    Merci pour le lien!!Oh j’avais pas vu que tu étais francais, j’ai parlé anglais pour rien :)Bonne continuation, et pour le blog, il va droit dans mes RSS ^^…

  10. 10
    Peekholes Says:

    IS it easy to add more fields?

  11. 11
    JP Says:

    Very nice! how can i put this form into my About page in Wordpress?Thanks!

  12. 12
    JP Says:

    Hi again, i translate the “LightForm\js\formcheck\lang” formcheckLanguage = {    required     : “Campo requerido.”,    alpha        : “Este campo acepta solo caracteres alfabéticos.”,    alphanum     : “Este campo acepta solo caracteres alfanuméricos.”,    nodigit      : “No se aceptan dígitos.”,    digit        : “por favor ingrese un número válido.”,    digitmin     : “El número debe ser de al menos %0″,    digitltd     : “El valor debe estar entre %0 y %1″,    number       : “Por favor ingrese un número válido.”,    email        : “Por favor ingrese un email válido:”,    email        : “Ingrese un email válido: <br /><span>Ej. sunombre@dominio.com</span>”,    spamcheck    : “<span>2 + 3 = ???</span>”,    phone        : “Ingrese un teléfono válido.”,    url          : “Ingrese una URL válida: <br /><span>E.g. http://www.dominio.com&lt;/span&gt;”,    confirm      : “Este campo es diferente de  %0″,    differs      : “Este campo tiene que ser diferente de %0″,    length_str   : “Texto muy corto, tiene que ser entre %0 y %1″,    lengthmax    : “Texto muy corto, debe tener un máximo de %0″,    lengthmin    : “Texto muy corto, debe tener por lo menos %0″,    checkbox     : “Por favor marque el chekbox”,    radios       : “Por favor seleccione un radio”,    select       : “Por favor seleccione un valor”}If you want i can translate all files, please help me with Wordpress!Thanks again

  13. 13
    Alex Says:

    I quite like this contact form you have made.If you are using this on your website then I reccomend you download the YUI Compressed mootools as it is only 65kb compared to the supplied 180kb.I am currently trying to turn this into a simple wordpress plugin.  It wont have any of the fancy functionality and admin interface of cforms though but you should still be able to get it to work with minimal php/html coding

  14. 14
    Jeeremie Says:

    Thanks for the info. I didn’t know about this YUI compressed tool. That’s good to know.

    It would be great you create a wordpress plugin. Let us know about it.

  15. 15
    Lawrence Salberg Says:

    Copyright in footer? How can you copyright this? You don’t have rights to standard scripting methods of JavaScript and PHP. Hey, it’s a nice form - don’t get me wrong - but think about how much you’ve been given by the community in terms of free info/advice on forums, and great languages like PHP and JS. To be part of the community, you have to give back. If you are going to “protect” your work, consider a Creative Commons license - which is a lot different than a copyright (which implies that you own all the intellectual property associated with your work - which you don’t).Better yet, just request that people give you credit - you’ll find most will - especially if they can post your Googlicious inbound link to a “credits” page somewhere on their site.Else bundle it up with LTS and charge for it.

  16. 16
    Jeeremie Says:

    Lawrence,

    Did you have a bad day? Where have you seen I put copyright by web-kreation? I say in the footer:
    “© Some Copyrights by their respective authors (if you are not sure visit authors’ websites).”

    This means copyrights by Moo Floor and BadBoy.ro for the PHP and JS.

    I have never pretended I knew any PHP or JS, neither I have intented to create something original. I just wanted to create a nice form using some existing scripts that I liked very much. And since I liked the result, I wanted to share it with others. Is there something wrong with that?

    Moreover, I say on my blog:
    “The CSS, XHTML, PHP and design is released under Creative Commons Attribution v2.5.”

    So next time, before you insult someone, read!!!!

    I am now waiting for your apologies.

  17. 17
    Lawrence Salberg Says:

    Hmmm…. no, not having a bad day. Just thought you didn’t know about that stuff. Turns out you do. Which is great. I first read about the copyright requirement on Smashing Apps here and then saw the same phrase repeated in the Download section above: “Use of this contact form is free of charge but the copyright notes in the footer must remain intact.”So, yeah, I, uh, apologize for not reading further and seeing the license information below. And for everyone’s benefit, the license info is in fact repeated in the actual php script download (not that I looked before).So, now that I apologized, I hope you’ll forgive me. Now, that I see the license info, all I can say is that it is, at best, a bit confusing - or perhaps conflicting information. Even if I had read down to the License section, I’m not sure I would have known which information supersedes which. But, I probably would have left a different comment entirely, admittedly. One asking a question, rather than assuming. You got me - two points for you. Your ball.

  18. 18
    Jeeremie Says:

    Yes, don’t worry. I accept your apologies. That’s not a big deal.

    Cheers!

  19. 19
    Ivo Says:

    its possible add new list menu or drop down menu in your script?whow? i try insert this list menu but i dont see nothing when i try in server!! can you explain me whow to work?thanks

  20. 20
    Quintin Says:

    ack Said:

    “Great. It works smoothly.Firebug detects a slight error on
    the congrats page though:obj has no properties while (obj.offsetParent)
    {on line190 of niceforms.jsKeep up the good work.”I have the same experience. Other than that it all works fine. Thank you for sharing this piece of work.

  21. 21
    ::: Web-Kreation.com ::: Freelance Web Designer Says:

    [...] LightForm is now a Wordpress plugin (only works with latest Wordpress v2.5.1). The plugin is called WP-Lightform and can be downloaded here. Thanks to Alex Rogers for the good work. [...]

  22. 22
    otavio Says:

    CARAAAAAA!!! vc me ajudou muito valeu mesmo. Espero manter contato

  23. 23
    mmartinovich Says:

    Hey! Love your stuff!
    I have a problem… I did everything right and it just won’t send email… it just gives me error…your massage faild to send!
    I can see css, nice form, form check works… it just wont send…

    thx!

  24. 24
    Jeeremie Says:

    @ mmartinovich: The script works fine. I have tried it few times and i could always send mail. Could it be a problem with your server or email address?

  25. 25
    mmartinovich Says:

    Everything is fine on server when I use another script… it sends I get it…
    Seems something is going on with send mail command…I can’t figure it out… everything works smooth except it won’t send…
    Once when I used another script it said ” You are coming from unauthorized domain… could it be something with this thing?

    Can you write down a send mail part of script ’cause I’m not so good with PHP…please! I love this thing! You did awsome job!
    I just HAVE to make it work!

    thx!

  26. 26
    mmartinovich Says:

    Ok… i figuered out why it wouldnt want to send email…
    had to add this line before mail function:
    ini_set(”sendmail_from”, “postmaster@domain.com”);

    Now it works like a charm!
    THX, bro!

  27. 27
    Jose Ramon Says:

    I am using your plugin in a wordpress page and I would like to have two different forms: a contact form and another one.
    I tryed to do that by having two plugins with different names but the same one and change the form in one of them. But the problem is that both appear with the code [lightform].
    Is there a way of having different forms that will show with different code in the posts?

    Thanks.

  28. 28
    Jeeremie Says:

    Jose,
    Do you have a url?

  29. 29
    Jose Ramon Says:

    This is my URL.

    Thanks.

  30. 30
    playmos Says:

    nice job man!
    very useful
    it was not 100% clear to me how text and translations are managed but now i think i’ve got them :)

  31. 31
    Allen Says:

    Hi,

    First, THANK YOU for this awesome contact form.

    Second, is there a way to limit a user’s URL input in the message box to at least 3? Spammers usually sends dozens of them. So I think this would be another good way to avoid spam.

    Thanks again and more power!

    _a

  32. 32
    Allen Says:

    If it’s not possible, is there a way to ban some specific words like ‘viagra’ in the message box?

    I actually tried doing it (please don’t laugh I’m no expert) but only works with one character (like ‘v’ ‘i’ ‘a’ ‘g’ ‘r’ ‘a’) :

    noviagra : /^[^"viagra"]+$/i,

    How to make it so it’s the whole word (”viagra” itself)?

    Thanks!

  33. 33
    mache Says:

    I’m using the wp plugin with your form. it’s working very good!
    just to send you the link to my web, as you asked for it.
    thanks again

  34. 34
    Jeeremie Says:

    Thank you Mache. However, it is Alex rogers you should thank for porting LightForm to Wordpress.

  35. 35
    Alex Says:

    Can someone tell me how I can redirect to a different page instead of going back to the source page?

  36. 36
    Justin Says:

    I’m getting this error:

    Firefox can’t find the file at /Users/laurenyoung/Sites/parsec/LightForm/.

    don’t know why…

    form looks great, I’d like to use it, if i can get this error thing figured out!

  37. 37
    Jeeremie Says:

    @ Alex: Open index.php and go to line 189. Change the message for this:

    <div class=\"MsgSent\">
    <h1>Congratulations!!</h1>
    <p>Thank you <b><?=$name;?></b>, your message is sent!<br /> I will get back to you as soon as possible.</p>
    <script type=\”text/JavaScript\”>
    <!–
    setTimeout(\”location.href = \\’http://www.yoursite.com\\’;\”,5000);
    –>
    </script>
    <p>Please, be patient. You will be redirected to the home page in 5 secondes.</p>
    </div>

    Don’t forget to change “yoursite.com” for your site. The script will redirect the visitor to the new page after 5 secondes.

  38. 38
    Jeeremie Says:

    @ Allen: You should better ask Luca, the author of Formcheck2. But, he is a very busy man. I don’t know if he will have time to answer you.

    @ Justin: no idea. Do you work on your localhost? If so, do you use a software such as EasyPHP?…You should tell us a bit more about your problem if you want someone to be able to help you.

  39. 39
    Justin Says:

    I’m working off my localhost. The error says can’t find file at :

    .

    I just uploaded the files to my server and tried to use it, and this is the error I’m getting.

    Thanks for any advice.

  40. 40
    Jeeremie Says:

    Could you send us the URL? We don’t see your error message.

  41. 41
    Q8iEnG Says:

    Hi, thanks my friend for the script I’ll use it in my other site
    http://www.clickclick.ws

    i’ll release soon the new design of it..

    have a good day :)

  42. 42
    Q8iEnG Says:

    I tried it,, but it give me an error message for failed sending :(
    check it here
    http://clickclick.ws/LightForm/index.php

    please reply to my email :)

  43. 43
    Jeeremie Says:

    This looks like you don’t have a SMTP server installed on your server? You will have to check this with your web hosting company.

    In any case I don’t think it is a problem related to my contact form unless you have screwed up the code. :)

  44. 44
    Q8iEnG Says:

    I didn’t use any of the code!

    just installed it in the site and it is not working!

  45. 45
    Jeeremie Says:

    So did you check if you have an SMTP server?

  46. 46
    Q8iEnG Says:

    I don’t think that it is from the SMTP!!

    because i’m using a script (contact form), that’s work just fine without any problem

    this is it
    http://www.q8ieng.net/mailform/mailform.php

    I’ll contact my support and i’ll let you know :)

  47. 47
    Jeeremie Says:

    Then, I really don’t know. Many people have downloaded this script and no one reported a similar problem. Besides, I have tested this script many times and it works just fine.

  48. 48
    Q8iEnG Says:

    they told me
    Yes, of course. We have SMTP server (EXIM) running on all our hosting servers!!

    so, where did u think the problem is?

  49. 49
    spfc Says:

    I am getting the following errors:

    Notice: Undefined index: name in D:\Sites\www.mydomain.com\form\index.php on line 12

    Notice: Undefined index: email in D:\Sites\www.mydomain.com\form\index.php on line 13

    Notice: Undefined index: website in D:\Sites\\www.mydomain.com\form\index.php on line 14

    Notice: Undefined index: subject in D:\Sites\\www.mydomain.com\form\index.php on line 18

    Notice: Undefined index: message in D:\Sites\\www.mydomain.com\form\index.php on line 27

    Can anyone help me? I didn’t touch anything from the code, just change the email address

  50. 50
    Q8iEnG Says:

    Thanks Jeeremine, I’ll try it :)

  51. 51
    Q8iEnG Says:

    Actually, I did everything, and everything is going alright

    except for the LightForm, I didn’t got how to place that script in it :\

  52. 52
    Meandme Says:

    Great ! But there is a problem with IE explorer 7, when i fill a box, the background image is leaving… just test… if you have a css solution for this, thanks a lot !
    Best regards !

  53. 53
    Jeeremie Says:

    Hello Meandme,

    It works fine for me in IE7. Has someone noticed the same bug in IE7?

  54. 54
    dosntMatter Says:

    Hi Jeeremie :)

    i said before: it works really great but if you disable Javascript, you can do what you want - also sending nothing - it comes the “congratulations Site.
    I have a idea:
    in your example fom lightscript use the tag
    and give a hint that they must activate Javascript
    Else it dont run/work

    If you have a better idea - go ahead

    Greets
    :)

  55. 55
    Xdiz Says:

    Thx very much for this work

  56. 56
    dosntMatter Says:

    Hi Jeeremie

    Here i am again - sorry for double-Posting - sorry for my bad english!

    “in your example fom lightscript use the tag
    and give a hint that they must activate Javascript
    Else it dont run/work”
    in your example from lightscript use the “NOSCRIPT” TAG.

    And: THX for that nice work !!

  57. 57
    Jeeremie Says:

    Hello dosntMatter,

    Actually your comment was posted but when I redesigned this site, I had to move things around and unfortunately, I lost the latest comments and yours as well. Sorry for that.

    I will think about this feature for LightForm but not right now. As you can see, this site is not quite finished yet.

    Thanks anyway for your comment. :)

  58. 58
    Roland Says:

    Hi, i get this IE7 Browser error message in german after sending the form:

    Line: 191
    Sign: 2
    Error: Object necessarily

    After i delete the complete Line 191 in the index.php the error-message was the same. Is there a javascript error?

    Thanks a lot!

  59. 59
    Jason Denison Says:

    Hey Jeeremie,

    Just wanted to say that I’ve searched the web for a very slick looking Contact Us Form that used some PHP, AJAX and JavaScript and your form by leeps and bounds is better than anything I’ve come across. It is freakn’ AWESOME!!! I haven’t installed it yet =) But saw the Demo and looked over the code. So intense!!

    Also thanks for being so detailed and actually taking the time to add comments in. Makes things so MUCH easier on newbies.

    THANKS!!!!!!
    jason

  60. 60
    flashios09 Says:

    Hey Jeeremie,
    your forms works with textinput and textarea but not with select,
    The alert box doesn’t appear when i add a

    Please choose
    Under 10
    Between 10 and 21
    Over 21

    i mean the script doesn’t validate it(select)
    can you help me,
    thanks very much for your work.

  61. 61
    flashios09 Says:

    I’m sorry, i forget to add for the XHTML code
    Hey Jeeremie,
    your forms works with textinput and textarea but not with select,
    The alert box doesn’t appear when i add a

    Please choose
    Under 10
    Between 10 and 21
    Over 21


    i mean the script doesn’t validate it(s