Wednesday, August 05, 2009

JavaScript : Validate for empty input

Don't :
if (form.input.value == "")

Do :
if (form.input.value.length == 0)
or
if (form.input.value.replace(/\s+$/, "") == "")

No comments: