View Full Version : Greying out input fields based on a date

06-19-2008, 12:15 PM
Hi all

I am new to this so apologies for the basic question. I posted it in the ASP forum and was told to come here. I have an ASP page where users can enter hours that they have worked. There is a start date of their job and an end date. I need to be able to grey out fields that fall outside the date range so for example, if they start on the Weds they cannot enter hours for the Mon or Tue. Would anyone be able to give me an idea on how I put together a function to do this please?

Many thanks

Philip M
06-19-2008, 12:39 PM
Too vague, I am afraid.

Please post the relevant code, that is the part with the text boxes for data entry. Plus any other existing validation of the entered dates.

06-19-2008, 12:47 PM
I dont have the code as I dont know how to write it..

Assuming I have
box 1 MonStart
box 2 MonLunch
box 3 MonFinish
box 4 MonTotal

box 1-3 are all input fields, box 4 is disabled.

I have an assignment start date which is already known and the validation is essentially;
MondayCheck = Weekending (the weekending Sunday date) - 6
If AssgtStart (assignment start - already pulled from a database) is less than MondayCheck then make Box 1-3 disabled as well..

Thats it in laymans terms i'm afraid... i just need the principle behind how i do that.

Philip M
06-19-2008, 01:13 PM
I think that this is a bit too big to be dealt with in this forum. The code for what you want plus the necessary validations is quite considerable. It looks as though it is a commercial application, and this forum is not a free coding service. We will happily help you with the code, but not write it all for you.

I suggest you ask a mod to move this post to Web Projects, i.e. paid assignments.

One way would be to have a set of radio buttons at the outset when your user can select Mon/Tue/Wed/Thur/Fri as the starting date. Then simply disable the textboxes relating to previous days as appropriate:-


if (document.myform.rad1([1].checked) { // Tuesday


06-19-2008, 01:24 PM
I didnt want you to write the whole thing for me, just give me a concept of how a function would be put together for something like this.

No worries, thanks anyway for the suggestion, i'll put it into practice and see how it works!

Philip M
06-20-2008, 08:46 AM
On second thoughts, it would be best to start with all the text boxes disabled.
Then a set of radio buttons to select the start day.
Then enable all boxes applicable to that start day or afterwards.