开发者

What's the difference between the input type "text" and "password" in an html form?

this question might seem stupid, but here's the situation: I'm trying to create an auto login page for my mail using jquery's post request, but it's not working, it works with all other pages except with webmail. So, trying to figure out what was wrong, I recreated the login form, here's the code:

<form id="form1" name="form1" method="post" action="https://login.hostmonster.com/">
<label>User
<input type="text" name="login" id="user" />
</label>
<label>Pass
<input name="password" type="password" id="pass" />
</label>
<input name="doLogin" type="submit" id="doLogin" value="Login">
</form>

The strange thing is when you change the input type of pass to text, the form doesn't work! I can't figure out why. Anyway, if you can tell me what's the real difference between the input type text and password (and not what it says everywhere on the net that the only difference is that when you type stars appear instead of characters) I would appreciate it. Also, do you think this is affecting my jquery's post? Here's the code for it:

$j.post('https://login.hostmonster.com/', { login: 'xxx@example.com', password: 'xxx' }, function(data, text){
 if (text=='success')
 {
  alert('Success '+data);
  }
  else
  {
开发者_开发技巧    alert('Failed');
  } });

Thanks a lot! Regards,

D


Another difference aside form the stars is you can't copy (Ctrl+C) the data in a password field.


One big problem that I see here is that the response will be stored in the variable data and not test. test is loaded with textStatus which, if I am not mistaken, only tells you whether your request went through. In other words, your script should be validating even with a bad password.

Here are some things to ask yourself, and perhaps let us know. First, is that the only thing that you changed? Does your form work without JavaScript? How does your script set and load the values entered? When you say that "it's not working", what is it not doing? Using a packet sniffer will help you see exactly what is getting sent as well as what is coming back.

Your browser should be interpreting "text" and "password" pretty much the same when it comes to data sent. However, some browsers don't follow the standards. Also, jQuery could be doing something different, but I've never heard of it before.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜