Date in form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhishekphukan
    New Member
    • Jul 2014
    • 34

    Date in form

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <SCRIPT> var date = new Date(); var month = date.getMonth()+1; var day = date.getDate(); var year = date.getFullYear(); 
    var output= month + '/' +day + '/' + year; 
    function compareDate() 
    { 
    if(Date.parse(document.form1.Date.value)<Date.parse(output))
    { 
    alert("You cannot select a date less than the current date"); 
    } 
    } 
    </SCRIPT>  
    <link type="text/css" rel="stylesheet" href="ExternalStylesheet/homestylesheet.css" />
    
    <style>
    
    button{
    border:2px solid navy;
    background:white;
    height:40px;
    width:120px;
    border-radius:5px;
    background-color:navy;
    color:white;
    }
    h1{
    text-color:navy;
    padding-left:80px;
    text-align:center;
    }
    td{
    font-size:20px;
    width:400px;
    padding:5px;
    }
    form{
    border:5px solid red;
    }
    h1{
    color:#C71585;
    }
    table{
    margin-right:400px;
    margin-left:400px;
    }
    </style>
    </head>
    <body>
    <form name="form1">
    <h1> Register Online</h1>
    <Table>
    <tr>
    <td>First Name</td>
    <td><input type="text" name="usrname" PlaceHolder="Enter Your First Name" required></td>
    </tr>
    <tr> 
    <td> Last Name</td>
    <td><input type="text" id="usrname1" PlaceHolder="Enter Your Last Name" required></td>
    </tr>
    <tr>
    <td>Age</td>
    <td><input type="number" id="age" min="0" max="200" PlaceHolder="Enter Your Age"><td/>
    </tr>
    <tr>
    <td>Gender</td>
    <td><input type="checkbox" id="gender" value="Male">M<input type="checkbox" id="gender1" value="Female">F</td>
    </tr>
    <tr>
    <td>City</td>
    <td><input type="text" id="city" PlaceHolder="Enter your City" required</td>
    </tr>
    <tr>
    <td>State</td>
    <td><input type="text" id="state" PlaceHolder="Enter your state" required</td>
    </tr> 
    <tr>
    <td>Location</td>
    <td><input type="text" id="location" PlaceHolder="Enter your location" required</td>
    </tr>
    <tr> 
    <td> Email ID</td>
    <td><input type="email" id="mail" PlaceHolder="Enter Your email address" pattern="[^@]+@[a-zA-Z]+\.[a-zA-Z]{2,6}" required></td>
    </tr>
    <tr>
    <td>Preffered date</td>
    <td><input type="date" id="Date" PlaceHolder="Enter your preffered date" required</td>
    </tr>
    <tr>
    <td>Contact Number</td>
    <td><input type="num" id="number" PlaceHolder="Enter Your Contact Number" required></td>
    </tr>
    <tr>
    <td>Address</td>
    <td><textarea rows="4" cols="16" id="address" PlaceHolder="Enter your address" required>
    </textarea></td>
    </tr>
    <tr><td>
    <Button type="submit">Submit</BUTTON></td>
    <td><BUTTON type="reset">Reset</BUTTON>
    </td></tr>
    </table>
    </form>
    
    </body>
    </html>
    plz can anyone help...its still accepting the date less than the current date..i tried a lot..but in my eyes i found nothing wrong..plz guide me anyone...
    Last edited by Rabbit; Aug 7 '14, 07:54 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • abhishekphukan
    New Member
    • Jul 2014
    • 34

    #2
    ok ok i got it..hehe..
    i forgot the onchange attribute after the id attribute

    Comment

    Working...