I have a site where i use readonly inputs. On the desktop I use js to select the input field on the first click.
<input readonly="readonly" type="text" class="select" value="Value to select">
$('.select').click(function(){
$(this).select();
});
But in Safari for iOS I can't the select the input text at all (long tap on the text).
Is there a way to make the text selectable?
have you tried something like this? Sometimes focus solves the problem, also perhaps the browser isn't aware that select() should trigger the event?:
$(this).focus().trigger('select');
Related
When double-clicking on a html page most browsers select the word you double-click on (or the paragraph you triple-click on). But it is not working properly on my html page specially for input field.
<input type="text" class="abc" id="abc" name="xyz" ondblclick="this.select()" value="">
you can Selet the value of input field by using ondblclick="this.select()"
for some reason I want to disabled an input text and for this I use this sample code :
$('#id').attr('disabled', 'disabled');
Is there any way to disabled an input text without use attribute disabled of input text, I mean for example use css or other ways?
In fact I want an input text act like a disabled one without change it attribute?
With Best Regards.
Try:
<input id="myTxt" type="text" onfocus="this.blur()"/>
Or by JS:
$('#myTxt').focus(function(){
$(this).blur();
});
You can't do it through CSS (unless you do something very complicated like hide the input and put a disabled-looking rectangle in its place). However, this will disable the input without changing the attribute:
$("#id").prop('disabled', true);
try this
<input type="text" disabled="disabled" value="" />
OK, I know how to detect keyboard input. I know how to focus on keyboard input.
But I want to know what the best practice is for detecting keyboard input => focusing to textarea or textfield => AND enter that key into the field.
Here's how it would work: I'm on a page. I type A. Then my textfield gets focused and A is typed into the field. This sounds trivial but actually I haven't found a simple way to do this. The reason is because the initial keyboard input event is not directed towards the textfield, and I need to propagate that event to the newly focused text field.
Is there a conventional approach to doing something like this?
Sample html:
<form>
<input type="text" />
<input type="text" id="thisguy" />
<input type="text" />
<input type="text" />
</form>
jQuery for above html
$(document).live('keypress', function (e) {
$('#thisguy').val($('#thisguy').val() + String.fromCharCode(e.which));
});
Needs to be cleaned up. Maybe set focus instead of changing the text value.
I need to know is there any function in sencha touch to know if the keyboard hides. I want to call a function when a keyboard hides.
Any Idea...
Pls check the below link. Hope this helps....
iPad Safari - Make keyboard disappear
To prevent showing the keyboard on:
<input type="text" name="someInput" />
for when you want to do something like use a jQuery UI datepicker...
add a readonly attribute like so:
<input type="text" name="someInput" readonly="readonly" />
If you are trying to be mindful of people with JS turned off, you could always leave off the attribute and add it in your code:
$('[name=someInput]').attr('readonly','readonly');
I have this code
<input name="mpan[]" value="" maxlength="2" size="2">
<input name="mpan[]" value="" maxlength="2" size="3">
<input name="mpan[]" value="" maxlength="2" size="3">
<input name="mpan[]" value="" maxlength="2" size="12">
What I have to do is I am provided with a large key for example 0380112129021. When I do Ctrl+C on that key and select any box and press Ctrl+V, the number automatically get pasted in different box, for example: first input box gets 03, next gets 801, next gets 112 and rest gets pasted on last one 129021.how do i achive this from javascript
If you're looking to catch paste events (rather than the literal Ctrl+V), the onpaste event may be for you, and is supported by most browsers according to this answer.
The splitting of the input value you could do using substring().
Easy. On each of the input box, add an onkeyup handler and inspect the input values.
Little clarification, you're trying to do something like serial/key input boxes, right?
okay if you have no idea you should read through some stuff.
i can recommend to read about
javascript - events.
especialy the onkeyup/onkeydown events
stringparsing (substring)
after that you will see the answer glowing on your screen ;-)
a little hint: if you store the pressed keys to a variable, it should be cleared after the action is triggered. and you should check what you have in you keypress cache and clear illigal input.