JavaScript : Validate for empty input
Don’t :
1 | if (form.input.value == "") |
Do :
1 | if (form.input.value.length == 0) |
or
1 | if (form.input.value.replace(/\s+$/, "") == "") |
Written by Komkid on August 5th, 2009 with
no comments.
Read more articles on JavaScript and Programming.
- [+] Digg: Feature this article
- [+] Del.icio.us: Bookmark this article
- [+] Furl: Bookmark this article