0
   

problem

 
 
nishil
 
Reply Wed 13 Aug, 2014 06:18 pm
<!DOCTYPE html>
<html>
<head>
<script>
function check()
{
var str=document.getElementById('loginNM').value;

if (str.lenght>10 || str.lenght<6 )
{
alert("name should be between 10 and 6");
}
else
{
alert("successful");
}
}
function verifypwd()
{
var strpwd=document.getElementById('pwd').value;
var strcnfpwd=document.getElementById('cnfpwd').value;
if (strpwd!=strcnfpwd)
{
alert("please check your password");
}
else{alert("correct")
}
}
function fillblank()
{
var name=document.getElementById('name').value;
var loginNM=document.getElementById('loginNM').value;
var strpwd=document.getElementById('pwd').value;
var strcnfpwd=document.getElementById('cnfpwd').value;
if (name===' '||loginNM===' '||strpwd===' '||strcnfpwd===' ')
{
alert("some fields are blank.......can't proceed")
}
else
{
alert("congrats u are registered")
}
}
</script>
</head>
<body>
<form name="myform">
name:<input type="text" name="name" id="name"><br/><br/>
deptname:<select name ="dept name">
<option value="EXTC">EXTC</option>
<option value="COMPUTER">COMPUTER</option>
</select><br/><br/>
gender:<input type="radio" name="male" value="M"/>M
<input type="radio" name="female" value="F"/>F <br/><br/>
Login name:<input type="text" name="loginNM" id="loginNM" onblur="check()"><span id="spanlogin"></span><br/><br/>
password:<input type="password" id="pwd"><br/><br/>
Confirm password:<input type="password" id="cnfpwd" onblur="verifypwd()"><br/><br/>
<input type="submit" onclick="fillblank()">
<input type="reset" >
</form>
</body>

</html>

in above program why my "if" condition gets false when its is a true ?
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 570 • Replies: 4
No top replies

 
maxdancona
 
  2  
Reply Wed 13 Aug, 2014 07:33 pm
@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.
nishil
 
  1  
Reply Thu 14 Aug, 2014 04:18 am
@maxdancona,
thank you for your help maxdancona
i just solve that problem by debugging
but there is one more problem im getting in first function "check( )"..there my if conditions gets false every time when it is also true..i tried that also by debugging but Im not getting the problem.
maxdancona
 
  2  
Reply Thu 14 Aug, 2014 06:18 am
@nishil,
You appear to have misspelled 'length'. That would explain the problem.
nishil
 
  1  
Reply Thu 14 Aug, 2014 06:32 am
@maxdancona,
hahahaha freak
thank you so much maxdancona
0 Replies
 
 

Related Topics

 
  1. Forums
  2. » problem
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 05/16/2024 at 09:23:33