1

I have a textbox for user to enter positive integer. User enters a lot of entries many times. Overtime, textbox has list of previous entries, when you start typing something similar to previous entry. Sometimes, user accidentally select those previous entries. I know this one of browser's features.

Is there anyway to clear these previous entries from javascript, or jQuery?

So, I'm thinking of using textbox (password mode) then unmask it with Javascript or jQuery. I think browser won't keep anything if textbox is for password.

How can I unmask textbox password with Javascript or jQuery if it's the right approach for this problem?

What I'm doing is to clear the history of the textbox I have on an ASPX page.

Thank you.

4 Answers 4

5

I think you are talking about the autocomplete feature - the browser gives a list of entries entered previously.

If you don't want it, then simple use autocomplete="off". There is no need of javascript (and therefore jquery)

Autocomplete can be turned off for one particular field or for an entire form.

<form name="form1" id="form1" method="post" autocomplete="off">  

<input type="text" name="text1" autocomplete="off">

But remember: This is a very useful feature, before turning it off make sure that it is essential to turn it off

Sign up to request clarification or add additional context in comments.

3 Comments

+1 and here's a link about that. and because it breaks html validation, you can do this dynamically like this, $('input').attr('autocomplete','off') - cheers!
I tried both AutoCompleteType="Disabled" and AutoCompleteType="None" but still it keeps history. As I mentioned this is Textbox control in ASP.NET page not HTML.
@Naraza - I think because it already cached it before. Try clearing the cache and/or try this textbox.autocompletetype of asp.net
2

If you have a master page, you can turn form autocomplete off like in the child page that you have that Textbox control on like this:

On page load event:

 >Me.Form.Attributes.Add("autocomplete", "off")

Also add this attribute to your Textbox AutoCompleteType="Disabled"

Comments

2

Do you want to change the input type from password to text ?

$('#yourField').attr('type', 'text')

1 Comment

This doesn't work, jQuery doesn't allow you to change the type attribute.
1

You can't change the "type" attribute. There is some jquery plugins for that.

This one is very simple to use: http://unwrongest.com/projects/show-password/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.