Detect empty values in JavaScript


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function isEmpty(obj)
  2. {
  3. if (typeof obj == 'undefined' || obj === null || obj === '') return true;
  4. if (typeof obj == 'number' && isNaN(obj)) return true;
  5. if (obj instanceof Date && isNaN(Number(obj))) return true;
  6. return false;
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.