Disabled Form Fields are not submitted…

By , Thursday 4th September 2008 11:01 am

As a quick note, as part of the ongoing estate agency software project I’ve gone back to editing date entry within the system. Now instead of allowing users to enter any old bit of text I’ve switched over to a Javascript date/time picker (for the short term) that allows user to ‘pick’ and date and time from a pop up window.

Now, for my old system  the picker would pop up when the user clicked on the input field. This however would allow the user to ignore the text field and still go and type any old thing into the field. This wasn’t ideal. So my solution was to ‘disable‘ the form field and put a span next to it with an onclick event calling the date/time picker. This meant that the user was almost forced into using the nice date/time picker so dates would go in with the correct format (although that still has to be validated!).

So I started passing my nicely formatted date-time(s) through the form and picking trying to pick them up with PHP‘s $_GET or $_POST variables. Unfortunately’disabled’ fields are not passed through form submissions This was very annoying. The solution was to enable the input element using javascript when the form was submitted using the onsubmit event.

This meant that the form data was passed through as required and was nicely formatted ready for validation…

Liked this post? Follow this blog to get more. 

Leave a Reply

You must be logged in to post a comment.

Panorama Theme by Themocracy

4 visitors online now
1 guests, 3 bots, 0 members
Max visitors today: 4 at 12:32 am UTC
This month: 15 at 10-10-2017 02:55 pm UTC
This year: 45 at 02-01-2017 10:28 pm UTC
All time: 130 at 28-03-2011 10:40 pm UTC