tonyf
tonyf

Reputation: 35557

Disabled Checkboxes

I basically have a couple of checkboxes in my form, that are not database items but am retrieving the source value based on a database column.

As I do not want the user to be able to change these checboxes, I have disabled these checkboxes.

When I query a record, the form at start-up retrieves the value for the checkbox with no issues.

The problem is, when I hit a validation error on my form when the page is submitted, my checkbox values that were originally retrieved as 'Y', i.e checked are now null.

How can I maintain these values when a validation error occurs?

Upvotes: 0

Views: 853

Answers (2)

npup
npup

Reputation: 2541

You can enable the checkboxes in question just before you post the form. Then they will be "just sent back", (hopefully) untouched.

As always, you must do your server side checks and not expect that form values and/or javascript have not been tampered with.

Upvotes: 0

Quentin
Quentin

Reputation: 943579

A disabled control will not be successful (that's the point of disabled).

Either go with a readonly control instead, or use a hidden input.

Upvotes: 1

Related Questions