html-input

Javascript Validation for Positive Integer Only Input

点点圈 提交于 2019-11-29 18:52:37
I have two text boxes, in it will only be allowed positive integers. If any alphabetical values or any other characters (e.g. %$&*£") are entered, an error message should be displayed and the values must not render a table. <input type="button" value="total" name="B3" onclick="powerOf();"> This line allows for calculation to be made, how can this validation stop this from happening when the incorrect values are entered?? As of now minus numbers are calculated and entering alphabets produces an empty table which is not quite what I was going for: (no1== no1.match(/^-\d+$/) ? alert("First number

How do I make a text input non-editable?

半世苍凉 提交于 2019-11-29 18:43:09
So I have a text input <input type="text" value="3" class="field left"> Here is my CSS for it background:url("images/number-bg.png") no-repeat scroll 0 0 transparent; border:0 none; color:#FFFFFF; height:17px; margin:0 13px 0 0; text-align:center; width:17px; Is there a setting or a trick to this, I was thinking of doing a label instead but how about the styling. How do I convert them and is there a better way or is that the only way? BoltClock <input type="text" value="3" class="field left" readonly> No styling necessary. See <input> on MDN https://developer.mozilla.org/en/docs/Web/HTML

Inline Disabling of Firefox Spellcheck?

a 夏天 提交于 2019-11-29 15:59:24
问题 I researched this a while ago and can't remember how to do it. I want to be able to prevent Firefox from running it's spell-checking functionality on certain input fields from within the page. I know it's possible but can't remember how to set it up. 回答1: Talk about having a big "duh" moment! I found the answer after some trial & error: <textarea spellcheck="false"></textarea> 回答2: The "spellcheck" attribute is currently an extra feature available only in Firefox, but it is being considered

Samsung Galaxy Tablet does not allow entering floating point numbers to inputs with “number” type

本秂侑毒 提交于 2019-11-29 13:10:45
Our client wants us to display numeric keyboard for an input field so basically I created a field like: <input type="number" name="quantity" step=".01" value="0.00" /> However, Galaxy Tablet erases "." and merges numbers before and after it, also disables "." in the keyboard. Is there another way to solve this issue or display numeric keyboard in input field when using type="text"? Note: I tried using pattern attribute (which works on iPhone). I tested this issue on various Android devices with Android 2.1+. I did not encounter this error on any other HTC and Samsung devices. maxweber Yes,

html input range step as an array of values

不问归期 提交于 2019-11-29 12:37:52
I've been playing around with the input type=range for the first time, and ideally I'd like to set the step value to an array of values. I looked over the spec and I see the possibility for a datalist but it seams the data list is only used for highlight values in a range, so to speak, but not setting the values in the range. So, something like this (ideally without a jQuery plugin, etc.): <input type="range" min="1" max="100" value="0" step="1,3,5,10,20"> According to the W3C spec , the values for step can be "any" or a positive floating-point number. That's it. The step attribute, if

Setting focus to a textbox when a function is called

♀尐吖头ヾ 提交于 2019-11-29 09:10:21
I currently have a textbox in my aspx: <input type="text" id="myTextbox" value="" /> I was wondering if I could set the focus (put my cursor in that text box) every time my JavaScript method is called. I was hoping it would work along the lines of this: function setFocus() { document.getElementById("myTextbox").Focus(); } Any suggestions? Invoke the lowercase .focus() function: function setFocus() { document.getElementById("myTextbox").focus(); } Try this: function setFocus(id) { document.getElementById(id).focus(); } In this way, your function becomes reusable. Just pass the ID of the html

HTML5 pattern for formatting input box to take date mm/dd/yyyy?

♀尐吖头ヾ 提交于 2019-11-29 06:05:04
问题 I used jQuery datepicker and I want to restrict my input field with a HTML5 pattern if a user, instead of getting the date from jQuery datepicker, types the date. How can I restrict my users with a HTML5 pattern so that they can just type the date in the form mm/dd/yyyy ? 回答1: Easiest way is use read only attribute to prevent direct user input: <input class="datepicker" type="text" name="date" value="" readonly /> Or you could use HTML5 validation based on pattern attribute. Date input

Removing input placeholder on a printable version of an html page

元气小坏坏 提交于 2019-11-29 05:46:32
I have a form with input fields. Each input field has a placeholder attribute. There is also a link displaying the printable version of the same form. My problem is that if I leave the placeholder attribute unchanged and the input field is empty, then the placeholder is actually printed, which is not very good. I am looking for a way to resolve this unfortunate behavior. Right now, the only thing I can think of is traverse the DOM in javascript and remove all the placeholder attributes when the printable version is given. Of course, when reverting back to the normal page view, the placeholder

HTML5 - input=number and incompatible browsers

拈花ヽ惹草 提交于 2019-11-29 05:41:40
问题 I want to use the html5 element <input type="number"> on my website, but i want to know what happens to this field in browsers that do not support this feature? Is it than a classic <input type="text"> field for those browsers? 回答1: When a browser does not recognize a particular type value for an <input> , it reverts to it's default value, which is text . So, all of the following are equivalent on browsers that do not support type="number" : <input type="number"> <input type=

When to use the disabled attribute vs the aria-disabled attribute for HTML elements?

泄露秘密 提交于 2019-11-29 05:27:37
I'm trying to make a form accessible. Should I make my inputs have both disabled and aria-disabled attributes, or just one? <label for="textbox1">Input</label> <input id="textbox1" type="text" name="Text Box" disabled> Or like this? <label for="textbox1">Input</label> <input id="textbox1" type="text" name="Text Box" aria-disabled="true"> Or like this? <label for="textbox1">Input</label> <input id="textbox1" type="text" name="Text Box" aria-disabled="true" disabled> aardrian I can take your example, put it in a CodePen , and check it in JAWS and NVDA (sorry, no VoiceOver today): <label for=