My database consists of some entries which are null (so they don’t affect max, min, etc..). When I pull all of the data from the database, I need to repopulate form fields with the values. Using .val(value) where value = null seems to work without any problems, but I’m not sure if this is a valid way to go about this. It doesn’t say anything in the jQuery documentation (that I can find) about using null as parameters to functions.
Edit: Changed NULL to null. I was still in PHP mode and that was a typo.
Different functions handle it in different ways, but for
.val()specifically, yes, this is perfectly valid:If you look at the
.val()source, you can seenullis converted to an empty string,""before it’s used: