Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert null value into a text input

I'm pretty sure it's not possible to do this but I'm still asking for it.

Is there a way for a user to insert a null (or an undefined) value into an html text input?

I need to distinguish between a null value and an empty string and I would like to allow the user to set this value into a single input.

For what I can see across the web, the standard solution to this problem is to match the text input with a checkbox that tell if the value is null or not. From my understanding, the limitation is linked to the fact that the textbox can hold an empty string but not a null value so that's why I think it's not possible to do exactly what I want.

like image 572
The_Black_Smurf Avatar asked Jun 21 '13 16:06

The_Black_Smurf


1 Answers

You can't tell a text input to have any kind of null value. Empty checkboxes have a value of an empty string '' by definition. The best way to do it, as you say, is to have a checkbox that toggles the disabled property of the text input, which gives a similar semantic.

like image 133
lonesomeday Avatar answered Oct 09 '22 03:10

lonesomeday