Javascript is very flexible with regards to checking for “null” values. I’m guessing you’re actually looking for empty strings, in which case this simpler code will work:
if(!pass || !cpass || !email || !cemail || !user){
Which will check for empty strings (""
), null
, undefined
, false
and the numbers 0
and NaN
Please note that if you are specifically checking for numbers it is a common mistake to miss 0
with this method, and num !== 0
is preferred (or num !== -1
or ~num
(hacky code that also checks against -1
)) for functions that return -1
, e.g. indexOf
)
Related Posts:
- Is there a standard function to check for null, undefined, or blank variables in JavaScript?
- Which equals operator (== vs ===) should be used in JavaScript comparisons?
- Sort array of objects by string property value
- Compare two dates with JavaScript
- JavaScript null check
- JavaScript null check
- How to resolve TypeError: Cannot convert undefined or null to object
- How can I determine if a variable is ‘undefined’ or ‘null’?
- How can I check for an empty/undefined/null string in JavaScript?
- Anagrams finder in javascript
- What is the difference between null and undefined in JavaScript?
- Origin null is not allowed by Access-Control-Allow-Origin
- How to check if a variable is not null?
- Checking for duplicate strings in JavaScript array
- Cannot read property ‘length’ of null (javascript)
- How to check for an undefined or null variable in JavaScript?
- Wildcard string comparison in Javascript
- What does “javascript:void(0)” mean?
- For-each over an array in JavaScript
- How can I remove a specific item from an array?
- require is not defined? Node.js
- function updateMap for Google Maps API
- Loop inside React JSX
- Encode URL in JavaScript?
- JavaScript “Uncaught TypeError: object is not a function” associativity question
- Mongoose – What does the exec function do?
- Developing an ad with MRAID.js
- ReferenceError: Invalid left-hand side in assignment
- How to detect Safari, Chrome, IE, Firefox and Opera browser?
- Javascript versioning to avoid caching, difference in these practices?
- jQuery animate backgroundColor
- JavaScript get element by name
- ReferenceError: document is not defined (in plain JavaScript)
- JavaScript innerHTML not updating element
- Palindrome check in Javascript
- Console is throwing Unterminated JSX contents error
- Console.log not working at all
- Blocked script execution in because the document’s frame is sandboxed – Angular application
- Node update a specific package
- How to fix RichEmbed Discord.js
- How to convert selected HTML to Json?
- Express error – TypeError: Router.use() requires middleware function but got a Object
- How to use Javascript to read local text file and read line by line?
- Why is the jquery script not working?
- JQuery Datatables : Cannot read property ‘aDataSort’ of undefined
- includes() not working in all browsers
- Why does JSHint throw a warning if I am using const?
- Uncaught TypeError: .indexOf is not a function
- Get all non-unique values (i.e.: duplicate/more than one occurrence) in an array
- How to set onClick with JavaScript?
- How to get current date in jQuery?
- Print the contents of a DIV
- Remove all special characters except space from a string using JavaScript
- How to Scroll Down – JQuery
- How can I use webpack with express?
- JavaScript check if variable exists (is defined/initialized)
- Embedding instagram webpage inside an iframe
- Do something if screen width is less than 960 px
- is there something like isset of php in javascript/jQuery?
- jQuery – Dynamically Create Button and Attach Event Handler
- Highlight a word with jQuery
- Javascript: ‘window’ is not defined
- Javascript – Replace html using innerHTML
- Syntax error: Illegal return statement in JavaScript
- How do I handle newlines in JSON?
- Update style of a component onScroll in React.js
- Fire oninput event with jQuery
- javascript includes() case insensitive
- Reading local text file into a JavaScript array
- “NS_ERROR_DOM_BAD_URI: Access to restricted URI denied”
- How can I unset a JavaScript variable?
- D3.js: what is ‘g’ in .append(“g”) D3.js code?
- Correct modification of state arrays in React.js
- Angular 2 Sort table columns
- Reset Undo on the tinymce editor
- Combine enqueue js without affecting dependencies
- WP Customizer set a value via javascript (to create presets)
- JavaScript in page doesn’t open new window [closed]
- wp_enqueue_script adds only the first script
- Add javascript to a woocommerce page template
- Dynamically insert values in a WordPress SelectControl Options field
- Vimeo froogaloop
- can a buttongroup have a label?
- Preloader for a WordPress Site
- Trying to integrate Zoho Campaign Form [closed]
- InnerBlocks restricting does not work on nested blocks
- How to open the add media dialogue it in a certain state / tab?
- Removing auto versioning of JS and loading to header
- How WP does Mortgage affordability calculation
- Putting custom html/js page into Elementor as it’s own block
- Drag-to-Scroll Landingpage
- Easiest way to find JS conflicts
- Nothing in dashboard that uses javascript works
- Update block once an API request returns with a value
- XMLHttpRequest of admin data to public
- How to execute WP shortcode in a javascript string “”
- Loaded JavaScript file not showing [duplicate]
- PHP or JS for header image rotator?
- Replacing & in JS code on pages
- Uncaught ReferenceError: tippy is not defined