clear suggestion box of input field [duplicate] - javascript

This question already has answers here:
How do you disable browser autocomplete on web form field / input tags?
(101 answers)
Closed 8 years ago.
I'm having a lo-gin page in that i just want to clear suggestion box like if 10 users lo-gin from that lo-gin page and when 11 user try to lo-gin from same lo-gin page and when he click on that input field he gives all 10 the names as suggestion i don't want that user know the name of previously lo-gin users please help i already tried autocomplete in input field as well as on form but it won't help I'm a fresher if i made any mistake in writing please consider...
<input class="input-field" id="userName" name="userName" type="text">.

Try autocomplete property of input:
<input class="input-field" id="userName" name="userName" type="text" autocomplete="off" />
^^^^^^^^^^^^

Related

How to show confirm message when form have been changed? [duplicate]

This question already has answers here:
Generic way to detect if html form is edited
(8 answers)
Closed 2 years ago.
I have a form which contains a lot of elements. Whenever I change an element (for example, a textbox or a text area), and then I go to another page, the browser will display a confirmation message for me to confirm if I'm sure I want to exit.
Here is my simple form, not the real one:
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit" value="Submit">
</form>
So, when I edit the FirstName or the LastName and go to leave the page, the confirmation message will appear. But when I delete all the changes and go to leave the page, the confirmation message won't appear anymore. And because I also use my form when I insert and edit, I cannot just simply compare between the input fname and "" (for example), but I need to compare the original data and the new data.
Try Like this:
<input type="text" id="fname" name="fname" onfocus="fnm=this.defaultValue;" onblur="if(fnm!=this.value)confirm('Changed!');" >
may Help!

Remove autocomplete from a SELECT with HTML [duplicate]

This question already has answers here:
How do you disable browser autocomplete on web form field / input tags?
(101 answers)
Closed 4 years ago.
I have a problem with the autocomplete in HTML, I'd like to remove it from a SELECT in a web page, so it doesn't appear over the page:
This is what I want because I'm printing the result in the bottom.
<form>
<input type="text" id="nameSearch" name="nameSearch" onkeyup="searchInput(this.value)">
<div id="searchOutput"></div>
</form>
I tried to add the autocomplete tag, but it works only with the INPUT tag.
<input autocomplete="off">
To Prevent autocomplete a field:
<form>
<input type="text" id="nameSearch" autocomplete="false" name="nameSearch" onkeyup="searchInput(this.value)">
<div id="searchOutput"></div>
</form>

hiding text entered in a type text input [duplicate]

This question already has answers here:
remove value attribute of input element using CSS only
(4 answers)
Closed 5 years ago.
I have a card reader which connects to computer via USB,it's supposed to print a 10 digit number when an input is focused on and a card is placed over the card reader, it works fine but I need the code to be invisible. when I hide the text using color:transparent, the text is hidden but when the user double clicks on the input it shows the text!
Thanks in advance.
Use this
<input type="password" name="pin" value="abc123">
And if you want to hide it completely then use
<input type="hidden" name="pin_hidden" value="abc123">
Please see below-
.hide {
text-indent: -99em;
}
<input type="text" value="123456789"><br>
<input class="hide" type="text" value="123456789">

I am developing firefox extension and wanted to count total number of text box of webpage but I wanted to ignore hidden textboxes. How to do this? [duplicate]

This question already has an answer here:
I am developing firefox extension and wanted to count total number of text box of webpage so how to count text box? [closed]
(1 answer)
Closed 9 years ago.
I am developing firefox extension and wanted to count total number of text box of webpage but I wanted to ignore hidden textboxes. How to do this? Every webpages has some hidden text fields for future reference so how to ignore them so that i can count only those text boxes which i can see.
use input:visible to find all non hidden text elements
<!-- assuming you have included jquery-->
<div id="test">
<input type="text" hidden>
<input type="text">
<input type="text">
<input type="text">
<input type="text">
</div>
<script>
alert($('#test').find('input:visible').length);
</script>
http://jsfiddle.net/2ff2Y/

Javascript "watermarks" for textboxes [duplicate]

This question already has answers here:
How do I make an HTML text box show a hint when empty?
(22 answers)
Closed 6 years ago.
I would like to know how to put text in a textbox when the page loads. Example: If I have a login page, I would have 2 textboxes named "username" and "password". When the page loads I want the the textbox to load with "username" written inside, so I won't have to put a label for that outside. But when the user clicks inside textbox it should disppear. How do I do this?
<input name="q" onfocus="if (this.value=='search') this.value = ''" type="text" value="search">
...from the Stack Overflow search box.
You could also add the onblur event to check: if (this.value=='') this.value = 'search'
This would re-print the watermark when the user clicks outside the textbox and the field is empty.
A more modern way is to use "PlaceHolder"
<input type="text" placeholder="search" />
There are a lot of tutorials on how to do this. Here's one walkthrough using the jQuery javascript framework.
Here's another popular blog post about it, just using regular javascript.
In laymen's terms:
When focusing on the input, if the value is "Username" then set it to ""
When removing focus from the box, if the value is "" (i.e. nothing was entered), reset it to "Username" to still provide feedback to the user since they haven't yet entered data
The code:
<input value="Username" onfocus="if(this.value=='Username') this.value = ''" onblur="if(this.value=='') this.value = 'Username'" type="text" />
JS:
function clearDefault(ctl){
if(ctl.value==ctl.defaultValue) { ctl.value = ""; }
}
In your textbox include onfocus="clearDefault(this)" and set its text to "username" or "password".
See this article http://www.alistapart.com/articles/makingcompactformsmoreaccessible. Of course, if you are using jQuery, there are "Label over" plugins.

Categories

Resources