A simple form with required fields form validation

Discussion in 'JavaScript' started by Axus Technologies Inc., Aug 17, 2009.

  1. #1
    Hi...

    I need a simple form with some fields and from that fields, some are required fields.
    I also need a date time picker for one field..
    Let me know,if anyone can help,then I can attach my existing form file here ..

    Im ready to make it a paid service, as long as someone helps me nicely in this :)
     
    Axus Technologies Inc., Aug 17, 2009 IP
  2. Mastermaniac

    Mastermaniac Peon

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    So, you just want a simple form validator?


    OK, you can do that like this..

    
    <script type="text/javascript">
    function val(){
    var f=document.forms[0];
    if((f.name1.value=="") || (f.name2.value=="") || (f.name3.value=="")){
    alert("Please enter the values correctly!");
    return;
    }
    else
    {
    f.submit();
    }
    }
    </script>
    <form>
    Username : <input type="text" name="name1"><br>
    Password : <input type="text" name="name2"><br>
    Email : <input type="text" name="name3"><br>
    <input type="button" onclick="val()" value="Submit">
    </form>
    
    Code (markup):
    As simple as that! :)
     
    Mastermaniac, Aug 18, 2009 IP