Tony didn't get any cake

  1. Home
  2. About
  3. Subscribe
  4. Archive
  5. Random

Tony didn't get any cake

Newer
Older
  • all for a lousy “

    I have joked before that a lot can ride on a missing ” but I didn’t head my own warning.

    I have been trying to get the form on my site to validate for days. Literally days. I have been pulling my hair out going over the code letter by letter, I tried several different types of Javascript codes - and all the time I secretly wondered:

    Is it possible to validate a form with Javascript and then send it to be processed by PHP?

    I began to think not. No matter how much I tried I could just not get my form to use javascript and PHP at the same time.

    ThenĀ  I discovered the culprit. A missing “.

    So in case you were wondering it is possible. And having scoured the internet and tested almost every script - I can say I found one of the easiest ones:

    This little script will test if you have empty space in a form:

    function validate_form ( )
    {
    valid = true;

    if ( document.NAMEOFFORM.NAMEOFINPUT.value == “” )
    {
    alert ( “Please fill in the your first name” );
    valid = false;
    }

    Then all you need to is reference it in your form like thus:

    <form name=”NAMEOFFORM” method=”post” onsubmit=”return validate_form ( );” action=”YOURFILE.php”>

    And REMEMBER that darned ” after your validate_form()

    Posted on June 2, 2009
    Comments (View)
  • blog comments powered by Disqus
  • whatidone
  • throwing-myself-into-the-world
  • brilliant-at-whatever

Field Notes Theme. Designed by Manasto Jones. Powered by Tumblr.