@nishil,
Which if statement is giving you the problem?
If I had this problem, I would add a 'debugger;' statement. I would use Chrome. I would turn on developer tools ('F12') before loading the page. This will let you see the value of variables.
If the problem if statement is this one...
Quote: if (name===' '||loginNM===' '||strpwd===' '||strcnfpwd===' ')
I would check to see if these variables might be 'undefined' instead of empty strings.