I have a problem to simply clear TextBox text ... I am using asp.net and bit of JS for project.
But it seems Mozzila is to strong for my code and now it's bugging me.
Idea is simple ... user can log in, and as always mozzila ask "Save credentials" which is fine

But if user forget his password, select the link, I send him mail with URL, he comes back to new page which got text boxes

And for some reason Mozzila see my first TextBox as the one it "remembered the credentials"

So i tried next things
<script type="text/javascript">
$(document).ready(function () {
document.getElementById("MainContent_txtNewPass1").value = "";
document.getElementById("MainContent_txtNewPass2").value = "";
});
</script>
And
protected void Page_Load(object sender, EventArgs e)
{
txtNewPass1.Attributes["AUTOCOMPLETE"] = "off";
txtNewPass2.Attributes["AUTOCOMPLETE"] = "off";
txtNewPass1.Text = "";
txtNewPass2.Text = "";
}
Which didn't worked, as I wouldn't be asking this question ... IDs of those asp:TextBoxes are different, I don't understand why is this happening or how to stop it from happening?
I am sure it's problem with Mozzila credential saving, as once I delete saved password, problem is gone. But at the end of a day, i just want to clear that TextBox.Text
If anyone gets a same problem ... I solved it but using
window.onload = function () {
document.getElementById("MainContent_txtNewPass1").value = "";
document.getElementById("MainContent_txtNewPass2").value = "";
}
Instead $(document).ready(function () {
Try this answer, the syntax is slightly different from what you have: https://stackoverflow.com/a/9686424/5013141
Instead of
txtNewPass1.Attributes["AUTOCOMPLETE"] = "off";
try this:
txtNewPass1.Attributes.Add("autocomplete", "off");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With