Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select all (Ctrl+a) keyboard button not working for input filed inside the HTML5 sortable

I've used this HTML5 sortable plugin for drag-drop. Inside that draggable section, I've editable text filed. At the time of editing, when I tried to select all text of input field by keyboard command ctrl + a, I noticed that the text had not been selected. At first, I don't understand what's the problem. For testing, I put a normal textarea inside sortable content and noticed that also not works! So, this is the issue of HTML5 sortable plugin. Here is my fiddle where you can see that first editable text's input (which is outside/above of "Sortable Content start:" text) is working by ctrl + a command where remaining input fields inside sortable content don't work with ctrl + a. How can I fix this?

like image 816
user1896653 Avatar asked Jan 27 '15 13:01

user1896653


People also ask

How do you restrict the input field alphabets?

The HTML <input> tag is used to get user input in HTML. To give a limit to the input field, use the min and max attributes, which is to specify a maximum and minimum value for an input field respectively. To limit the number of characters, use the maxlength attribute.

How do you input only numbers in Javascript?

By default, HTML 5 input field has attribute type=”number” that is used to get input in numeric format. Now forcing input field type=”text” to accept numeric values only by using Javascript or jQuery. You can also set type=”tel” attribute in the input field that will popup numeric keyboard on mobile devices.

How do you input only numbers in HTML?

The <input type="number"> defines a field for entering a number. Use the following attributes to specify restrictions: max - specifies the maximum value allowed. min - specifies the minimum value allowed.

How do I allow only input numbers?

1. Using <input type="number"> The standard solution to restrict a user to enter only numeric values is to use <input> elements of type number. It has built-in validation to reject non-numerical values.


1 Answers

Adding this to your code should do it:

$('.section-sortable').keydown(function(e){
    if (e.keyCode == 65 && e.ctrlKey) {
        e.target.select()
    }

})

It basically listens to keydown event on your section and if the keydown detects a Ctrl-A it "selects" the target.

Fiddle

like image 160
martskins Avatar answered Nov 14 '22 06:11

martskins