Textbox readonly attribute issue with my struts application - javascript

In my struts 1.2 application i have some fileds in text box which is in readOnly= "true" always. I will populate all the values with out any problem, but the problem is when i click on the text box the cursor is blinking on it when i try to hit backspace button it goes to my previous page end up with session expired error on the previous action.
also some scenario I am populating the text box value and i am making that text box to readOnly = "false" allowed user to end some value here when they press backspace to remove the values which is there already it goes to previous page.
Please help to avoid this situation.
Thanks in advance!

Use disabled rather than readonly. Disabled elements cannot be focused, so no confusing blinking cursors.
<textarea disabled="disabled">content</textarea>

Related

Chrome extension: Watch for changes on an input box and trigger event based on whats inputted?

Problem - Watch for active input boxes in a page and trigger events if specific words are entered into the input box
Steps
Click 'reply or reply all'
Input box becomes active
Enter |intro
|intro text gets replaced with long form version. The |intro is like a snippet or short code
Heres what I'm thinking
Query all input boxes on a page
Check for input with focus
Add event listener on input to check for keyup events
Conditional statement to check if string contains specific snippet/short code
If condition is met then replace snippet with long form text
What do you think of my approach to this functonality

valueHelpOnly for smart filter bar in sapui5

I have included smartFilterBar:ControlConfiguration control in Smart Filter Bar. One of the controls has F4 value help. In this control, I can enter some text manually also. How can I disable entering the text and display value help dialog only on click of that filed. In short I want a feature similar to "valueHelpOnly" in Input field which disable manual entry of data.
Programatically you can do it in a following way:
myControl = this.getView().byId("smartFilterBar").getControlByKey("myControl")
myControl.setValueHelpOnly(true);
After that, clicking on selection field will automatically open the value help dialog.

How to manually focus to next input field with jquery virtual keyboard?

I am using jquery virtual keyboard in my page. i have two input boxes. On my page load i manually focus the first input field. so that virtual keyboard enabled. on pressing VK Tab in focus to next input field. so far fine. But as per new requirement when the user enters 8 characters in the first input field then the focus should move to next input field. I tried adding the condition in the virtual keyboard button click event and set $('#nexIPField').focus() but not working as expected. How to achieve this?
What i am thinking is manually trigger the tab key event solve the problem. If it is right how to trigger the tab key event?
One way to do this would be to associate an onchange event on your textbox.
Call a function on change to check the number of characters which have been typed. Once it reaches 8, trigger a focus on your next sibling.
<input type='text' onchange='checkChars()'/>
Javascript:
function checkChars() {
//take length of that input field and check for 8
$(this).next().focus();
}

force the focus to leave a form field with jQuery in iOS when selecting non-input element

Using jQuery or something similar, is it possible to detect when a user has clicked away, effectively removed focus, from a form field in iOS? I have conventional form which has a first name, last name, address line 1, address line 2 etc.
On an iPad when you select a form field the only way to leave that form field is to select another field in the form by clicking it or by hitting the Previous or Next buttons in the keyboard pane.
As the keyboard pane is shown clicks to other non-input elements on the page are ignored, so focus remains on the form field.
Is there a way with jQuery/JavaScript (or anything else) to force the focus to leave the form field if I click away from it by clicking a non-input form element?
Here's an example of what I mean. In the screen below, when the focus is on the Line 1 element I can't move out of it by clicking a non-input element.
Try just doing a quick blur() on the form, that might work.
$('body').on('click', function () {
$('form').blur();
// And since you said selecting an anchor might help, potentially doing a:
$('a#whatever').blur(); // might do the trick too
});

jQuery / Javascript pass focus to next element while tabbing through page

I'm building a 'tag input' plugin with jQuery at the moment and I've hit a small stumbling block.
I'm adding a button after a text input in a form, and using javascript to provide functionality for the button. When the button is clicked (or return is pressed in the input), the value of the input is added to a list of tags. The input is then cleared and refocused.
My problem occurs when I tab through the interface, the button after the input gains focus when you tab to it but I want to cancel this behaviour. I could just blur the button but I'd rather the button passes focus to the next focusable element.
e.g. I have three inputs in my form: text-input-1, button, text-input-2. When text-input-1 is focused and I press tab, I want focus to jump to text-input-2 rather than the button.
Can this be done? Thanks in advance.
This is easy enough in IE, which accepts a negative integer for the tabIndex property which will remove it from the tabbing order:
<input type="button" tabindex="-1" value="Can't tab to me!" />
This isn't part of the HTML 4.01 specification for tabindex, which only allows an integer between 0 and 32767. However, it is specified in the HTML 5 drafts and supported in most major browsers.
The easiest method I can think of in browsers that don't support it would be to wait for the input's onkeydown event and check for the tab key. If the tab key is pressed, disable the button and set a timeout with an interval length of 0 to enable the button again.
Change the tab index order, give text-input-1 tabindex to 100 and text-input-2 to 200 and for the button any number greater than 200. It should solve the problem.
Ah, I've answered my own question with help from Teja (+1).
All I needed to do was apply a negative tab index to the button!

Categories