views:

50

answers:

3

I have a textbox for user to enter positive integer. User enters a lot of entires many time. 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 fromjavascript, 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.

+1  A: 

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

$('#yourField').attr('type', 'text')
Greg B
+5  A: 

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

Nivas
+1 and here's a [link](http://www.petefreitag.com/item/481.cfm) about that. and because it breaks html validation, you can do this dynamically like this, `$('input').attr('autocomplete','off')` - cheers!
Reigel
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.
Narazana
@Naraza - I think because it already cached it before. Try clearing the cache and/or try this [textbox.autocompletetype](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.autocompletetype.aspx) of asp.net
Reigel
+2  A: 

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"

Angkor Wat