Just started learning JavaScript can someone please tell me what is wrong with this code

<!DOCTYPE html>

<h1>Password Requirement</h1>

<p id="demo">Please enter your password</p>
<input id="myInput" type="text" >

function myFunction()
var a=document.getElementById("demo")
var b=document.getElementById("myInput").value
var c=document.getElementById("myBtn")

if (b=="26a8f9e"(b))


<button type="button" id="myBtn" onclick="myFunction()">Submit</button>


b=="26a8f9e"(b) whould be b === '26a8f9e'

With that said, this does not provide any security whatsoever since anyone can just view source and get the password.

Member Avatar

Use server-side processing to deal with passwords. If you don't want a page refresh on form submit, you can use Ajax. js can help with validation only to notify users that they've typed illegal characters if the only ones allowed are a-Z0-9 for example. As mentioned, anything in your js files or js scripts within html pages can be read - even if you use an obfustator. It is not secure.

You should end every statement of javascript with semicolon.