I'm trying to compare two variables values, but it is not working as expected, I need to compare a static id (0000) four zero's with what has been entered by user(userInput), I tried to print values but it prints only first zero and skips rest, also it compare user value with only first zero, I need to compare user entered value with exact four zeros Any idea what is wrong?
function showProfile() {
var checkEmpId= document.getElementById("emp_id").value;
var staticEmpId=0000;
console.log(+checkEmpId); // from user Input
console.log(+staticEmpId); // shows only one 0
setTimeout(function(){
// I thought this will help ,still not working
if(parseInt(checkEmpId,4)== parseInt(staticEmpId,4)){
// I tried below as if statement but no luck
//if((document.getElementById("emp_id").value)="0000"){
console.log("Yay, Got luck"); }
else
{
console.log("else block is now clalled");
errorProfileId();
}
},4000)
}
<label>INCR</label><input type="text" class="form-control" name="otp" id="emp_id" required size="4" maxlength="4">
<button type="submit" class="btn btn-default btn-success" tabindex="-1" id="register_emp_btn" dismiss="modal" onclick="showProfile();">Compare</button>
funcion showProfile(){
var checkEmpId= document.getElementById("emp_id").value;
var staticEmpId=1234;
console.log(+checkEmpId);
console.log(+staticEmpId);
setTimeout(function(){
if(parseInt(checkEmpId,4)== parseInt(staticEmpId,4)){
// if((document.getElementById("emp_id").value)="0000"){
var checkID=document.getElementById("emp_id").value;
localStorage.setItem("LSEmpId",document.getElementById("emp_id").value);
window.location.replace("signup_step2.html");
}
else
{
console.log("else block is now clalled");
ErrorProfile();
}
},4000)
}