Hi
Will you please share the code to compare boolean and string value with if condition in JavaScript?
if (true == 'true') { }
How can i compare this?
Hi makenzi.exc,
Refer below example.
HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <style type="text/css"> body { font-family: Arial; font-size: 10pt; } </style> </head> <body> <script type="text/javascript"> var isValid = "true"; if (JSON.parse(isValid.toLowerCase())) { alert('Valid.'); } else { alert('Invalid.'); } </script> </body> </html>
Demo
Screenshot
Downloads
Download Sample
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.