HTML Form Processing Tip

No, this isn’t something NEW, but a good reminder… I *assumed* it had been set up correctly to begin with, but I was wrong.

So when processing a form (ie: POST form data to a validation/storage function) any input elements with the DISABLED attribute are ignored. Nothing new; right.

But you might want to process them… maybe they’re required? Maybe you have some AJAX/javascript setup to keep the user from being able to enter BAD DATA or unwanted characters. Just maybe…

Well, to keep the functionality of NOT allowing them to do whatever it is you’re trying to keep them from doing switch the DISABLED attribute to READONLY. Let the AJAX/javascript function update your element’s value like it should, and the processing function/page will still be able to access the data within the POST.

Example:

<input type="text" id="emailer_start_date" name="emailer_start_date" value="" onClick="xajax_datePicker('emailer_start_date');" DISABLED>

This will update correctly, but the processing page will not treat it as an element to be processed, due to the DISABLED attribute.

<input type="text" id="emailer_start_date" name="emailer_start_date" value="" onClick="xajax_datePicker('emailer_start_date');" READONLY>

This has the SAME behavior as DISABLED, but allows you to process the value assigned to the input field.

This is great for keeping users from typing data in manually, especially in the event you use a date picker flyout.


Related posts:

  1. IE6/IE7; Select, Option + Javascript
  2. XAJAX, Follow the DOM syntax! (HTML)

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*