macek/jquery-serialize-object

Check box serialized twice with 'false'

ttamaranazc opened this issue · 1 comments

I'm serializing a form, when I check a checkbox(consider, id=mytestbox), it is serializing the checkbox twice with value 'false'.
It was expected that one with 'true' and another with 'false'.

Actual serialized string: mytestbox=false&mytestbox=false
Expected: mytestbox=true&mytestbox=false

I have read this article.
@macek

What could be the reason for this?

The reason for this is, check box value is 'false'. So it is serialized as 'false' even it checked.

issue: <input id="mytestbox" name="mytestbox" type="checkbox" value="false">

Fix: <input id="mytestbox" name="mytestbox" type="checkbox" value="true">