Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to set input values to empty string ("") results in setting them to "undefined" #53

Closed
sbull opened this issue Feb 11, 2012 · 2 comments

Comments

@sbull
Copy link
Contributor

sbull commented Feb 11, 2012

$('input').val('') sets the values to "undefined" (when placeholder isn't natively supported, e.g. IE), even if .placeholder() is never invoked.

Test case:

<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="jquery.placeholder.js"></script>
    <script type="text/javascript">
$(function(){
  $('form').submit(function(event){
    event.preventDefault();
    $('input').val('');
  });
});
    </script>
  </head>
  <body>
<form>
  Text: <input type="text" name="txt"></input><br />
  Email: <input type="email" name="eml"></input><br />
  Password: <input type="password" name="pwd"></input><br />
  <input type="submit" name="sbmt" value="test" />
</form>
  </body>
</html>
</pre>
@sbull
Copy link
Contributor Author

sbull commented Feb 11, 2012

A workaround is to add placeholder attributes to the fields (such as placeholder="").

@sbull
Copy link
Contributor Author

sbull commented Feb 12, 2012

Fixed by merge of pull request #54.

@sbull sbull closed this as completed Feb 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant