天道酬勤,学无止境

input

HTML5 INPUT type='number' - distinguish between focus and value-change mouse clicks

In the HTML5 INPUT type='number' the user can change the value by clicking on up/down arrows that are part of the INPUT box. The user might also click in the box for focus or for editing its contents. Is there any easy way to distinguish between these two activities in the click trigger? from @cvsguimaraes answer, which better demonstrates the theory. using his methodology, here is my finished(?) version. the purpose: make sure regular change triggers are called when using +/- to change data. // input/mouseup triggers to call change from +/- mouse clicks // want to wait 500ms before calling

2021-06-14 16:11:43    分类:问答    javascript   html   input   click

How to hide a dropdown when the user clicks outside of it

Below is a simplified version of the input dropdown I am working with. A basic summary of what it does is: if you focus on the input, a dropdown appears. If you click one of the options in the dropdown, the option populates the input and the dropdown disappears. This is achieved using onfocus and a functions I called dropdown(); and undropdown();. I'm in a dilemma, where I'm unable to make the dropdown disappear when someone clicks elsewhere. If I use onblur, it successfully hides the dropdown, but if you click on an option it doesn't populate the input, this is because, the onblur function

2021-06-14 14:29:37    分类:问答    javascript   html   css   input   drop-down-menu

Simple Python input error

I'm trying to write a code to edit a list and make it a palindrome. Everything is working except my input still gives me one error. When I enter a non-int into get_number_2, it crashes. def get_number(): num = raw_input("Please enter number between 100,000 and 1,000,0000: ") if not num.isdigit(): print "---------------------------" print "Invalid input: numbers only" print "---------------------------" my_main() else: return num def get_number_2(n): num = input("Please confirm the number you have entered: ") if num != int(n): print "--------------------" print "Entries do not match" print "---

2021-06-14 09:15:24    分类:问答    python   validation   input   int

How to make an input field have 100% width minus the width of the submit button?

I have a very basic single input field with a 'submit' button alongside it. The search button has a fixed width of 104 pixels. Both are wrapped together with total width 50% of the browser viewport. It is my plan to allow the input field to enlarge as the browser window enlarges. At the moment, for my specific browser window, I am having to fix the width of the input field to spread from the left of the wrapper to the left of the submit button. However, as I resize the window, it (obviously) doesn't adjust accordingly, and hence leaves a white space gap. I have not found an answer to this

2021-06-14 08:31:28    分类:问答    css   forms   input   resize

When a span element contains no text, fill with placeholder text

After a great answer I see this might be a possible duplicate of Placeholder in contenteditable - focus event issue I have an HTML <span> element with the contenteditable="true". My goal is to have a seamless 'input' field utilizing the span element. I'm having issues getting the following flow to work: The DOM loads with <span> editable and default text of 'Make a new tag ..' When User clicks on the <span> the text updates to say 'Begin typing ..' On first keypress, remove <span> text and begin filling with User input If the <span> has no text and the user is still editing, replace text with

2021-06-14 07:10:24    分类:问答    jquery   css   input

How to read an input file char by char using a Scanner?

I have to use Scanner, so is there a nextChar() instead of nextLine() method that I could use? Thanks!

2021-06-14 06:43:52    分类:问答    java   input   io

How to calculate the width of an input HTML element so that it matches the size of its content?

How to calculate the width of an input HTML element so that it matches the size of its content ? I already update an input on the fly as the user types : <input type='text' onkeydown='this.size=this.value.length' /> However, this does not seem completely correct because it does not take into account the fact that some characters are longer than others : I will get more and more whitespace if I type only some "l" characters the size will be insufficient if I type only some "w" characters How to proceed? PS: Why I want to do this (already answered this in a answer that was deleted)? I have

2021-06-14 06:43:42    分类:问答    javascript   html   css   input   auto-update

How to check if an input is disabled with JavaScript in Selenium

I'm building and automated test script for a webapp using selenium and I'm trying to use the waifForCondition function of the API where it will wait until a JS script evaluates to true. I currently have this source on the page: <input id="modifyHostsForm:idDnsIp0_0" type="text" name="modifyHostsForm:idDnsIp0_0" readonly="" disabled=""> Which should change to: <input id="modifyHostsForm:idDnsIp0_0" type="text" name="modifyHostsForm:idDnsIp0_0"> As soon as I put a certain value on another field and fire the "blur" event on it (and this field thus becomes "enabled"). And I'm trying to execute the

2021-06-14 06:40:44    分类:问答    javascript   input   selenium

Center text in html number input

I have a number input in html. I want to center the text (i.e. the input) that is inside. I of course did: text-align: center; which sort of works. The problem is though. The text is now centered when those arrows are shown. But when the arrows disappear, the text stays at the same position which now of course isn't the center anymore.

2021-06-14 05:40:22    分类:问答    css   html   input

jQuery Mobile focus next input on keypress

I have a jquery mobile site with a html form consisting of 4 pin entry input boxes. I want the user to be able to enter a pin in each input field without having to press the iphone keyboards "next" button. I have tried the following and although it appears to set the focus to the second input and insert the value, the keyboard disappears so the user still has to activate the required input with a tap event. $('#txtPin1').keypress(function() { $('#txtPin1').bind('change', function(){ $("#txtPin1").val($("#txtPin1").val()); }); $("#txtPin2").focus(); $("#txtPin2").val('pin2'); }); Is there a

2021-06-14 04:06:04    分类:问答    input   focus   jquery-mobile   tap