Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Date validation

  1. #1
    New Coder
    Join Date
    Dec 2009
    Posts
    42
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Date validation

    Hi,

    Got input boxes for begin and end dates - using JQuery for date picker calendar for each. Need to validate 2 things - 1 is that end date is => than begin date, 2 is that user enters date into begin date rather than just numbers.
    I got date picker JQuery from another office where I work and can not change their parameters or code. So my input boxes allow for date picker selection or manual data entry.
    The end date input box can be empty if user only inputting one day for begin date and not a range.
    Also have 3 more begin/end date input box sets which are not visible until user clicks "Add Row" button - one click, one set added. Want to insure if user added row and input date then removed row (clicked "Remove Row" button) that the data entered is removed and not inserted into database.

    Add & remove rows:

    Code:
    <script type="text/javascript">
    var showing = 0;
    
    function showAnother() 
    {
        if ( showing <= 3 ) 
        {
           ++showing;
           document.getElementById("row"+showing).style.display ="";
    	    	}
    	if ( showing == 3)
    		{
    		alert("Maximum number of rows allowed.");
    	}
    }
    </script>
    
    <script type="text/javascript">
    function removeRow() 
    {
        if ( showing >= 0 ) 
        {
           document.getElementById("row"+showing).style.display ="none";
    	   showing--;
    	    	}
    	if ( showing == 0 )
    		{
    	return true;
    	}
    }
    </script>
    Begin & end date input boxes:

    Code:
    <td><input style="width: 70px" type="text" id="startdate1" name="startdate1" /></td>
    <td><input name="stopdate1" style="width: 70px" type="text" id="stopdate1"/></td>
    Other 3 begin & end date input boxes same with names increased by one digit - startdate2/stopdate2, and so on to 4.

    Thanks,

    John

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,992
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    Have you tried using the search feature of this forum? This was covered very recently at

    Setting user inputed date. Post#7.

    If the display property is set to none, then the element is actually removed from page completely, and is not available.

    It is your responsibility to die() if necessary….. - PHP Manual


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •