In my web page: which is a jsp file
I have an input text, I type a text in it then I press enter an error occurs:
javax.servlet.ServletException: Request[/myAction] does not contain handler parameter named 'method'. This may be caused by whitespace in the label
text.
What can be the cause?
If you hit enter in one of the text inputs, browsers will act like the first button on the form was pressed & IE will not send any button related information to the server.
To avoid it all and make one input act just like multiple inputs, just add a 'hidden' text input
<input type="text" style="display: none" />
This input will force IE to act like the first button on the page was clicked when enter is pressed on this form.
For further info, go to Click here
Related
I'm working on an HTML form for a web app. I'm adding the enterkeyhint attribute to indicate and navigate to the next input until the last one submits the form.
The problem is that enterkeyhint doesn't navigate to the next input if its type is type=text.
This happens on Chrome/83.0.4103.101 for Android 7. In Safari the hints button appears but they all do nothing.
Example:
<form (submit)="submitForm()">
<div>
<label>Name</label>
<input type="text" enterkeyhint="next" inputmode="text" />
</div>
<div>
<label>Email</label>
<input type="email" inputmode="email" enterkeyhint="next" />
</div>
<div>
<label>Comments</label>
<input type="text" />
</div>
</form>
Focusing on Name input, the Next button doesn't do anything.
Focusing on Email input, it navigates to any next input (Comments)
Now, if I change the type=email for type=text it doesn't navigate to the next input.
Similar behavior happens for type=tel. It does navigate to the next input of the form.
Am I missing something to make this work?
Thanks
enterkeyhint is just a hint to the browser what to display on the virtual keyboard, but you need to implement the actual behaviour yourself. See for example Focus Next Element In Tab Index, or How to focus next input field on keypress if your DOM is simple enough that the input fields are siblings with the default tab order.
From the spec:
The enterkeyhint content attribute is an enumerated attribute that specifies what action label (or icon) to present for the enter key on virtual keyboards. This allows authors to customize the presentation of the enter key in order to make it more helpful for users.
There is nothing in the spec to suggest that enterkeyhint actually affects the behaviour of the Enter key.
I have text box that is in a partial and exists in a collection.
I added the required on the input box, when nothing is in the textbox and i hit submit shows field is required message and disables the form submit button. However, then when i go type something in the text box message field is required stays and form is still disabled.
I removed the novalidateattribute on the form in case that was causing this.
I have a form with some text input fields (let's say FirstName and LastName to keep it simple) and then a submit input field at the bottom of the form (with a value of Sign In)
When I type something in one of the text fields (such as typing John for the FirstName) and then press Enter on the keyboard, it automatically triggers the submit input field, as if I have actually clicked the Sign In button.
I understand the reason why it is doing this, however I need to find a work around so that if Enter is pressed, I can carry on typing in the rest of my form. I don't want the form to actually be submitted until someone clicks Sign In.
I have read a suggestion such as changing <input type="submit" value="Sign In">to <input type="button" value="Sign In"> instead, however if I do this it then makes the button un-clickable, and doesn't actually 'submit' the form.
Any suggestions?
I haven't included my code because I didn't feel it was necessary, as I'm sure there's a really simple solution I'm completely missing.. but if I really need to paste my code I can.. thanks.
Inline HTML:
<form onkeypress="return event.keyCode != 13;" ...>
...
</form>
That works by disabling the enter key for the entire form. (take note that this will stop you from making newlines in textareas)
Source
You can not for the input "text" but you can for input "area" because area input is not fixed.
because I am having some problems about when using onblur/onkeydown (for tabs) etcetera.
I 'd like to ask this question:
if I have a page with just one input text and I go there and I click the "tab" where is the focus going ? I'd like to know because I'd like to force the input text not to lose focus...
My page is like this:
<!docType>
<html>
<body>
<div><input type='text' /></div>
</body>
</html>
If you want to focus specifically that text field than use autofocus attribute
<input type="text" autofocus />
Or if you want to map the tabs in a custom way use tabindex attribute
Tab 2<br />
Tab 1<br />
Tab 3
When there is 1 input text field and there's nothing after that, not even a link than probably the focus will go to the address bar of the browser, or probably it will move to add on bar if the user is having any browser add on, on the add-on bar
In Chrome when you tab away from an input and there are no other elements with tab index on the page the focus changes to the browser's URL bar. There probably won't be anything you can do to prevent this happening.
When you tab again it will return to that element - again provided it's the only element on the page with a tab index.
When you then click back onto the page (not the input) the focus isn't naturally restored to the input field (again, testing in Chrome here), so you may need to use JavaScript to force the focus upon the element.
Can anyone explain this behavior? Pressing the Enter key in an HTML form's text box submits the form when the form contains a single text box, but not when the form contains two or more text boxes.
jsFiddle (one input): http://jsfiddle.net/gpPTa/
jsFiddle (two inputs): http://jsfiddle.net/fDbJt/
Unfortunately it's a default for the form to submit on enter with only one input.
You can either give each of them an javascript command that submits the form, or place a submit button with width: 0 and/or visibility: none.
For example:
<form>
<input style='width:0; visibility:hidden' type='submit'>
<input>
<input>
</form>
It seems that the browser assumes that since there is only one input, it is also the submit control. Focusing on it and pressing enter will submit the form, the same way as focusing on a submit button will behave.
When you add type="submit" to one of the <inputs>, you can use as many others as you like and the form will be submitted by pressing enter.
I don't have any references to back this up, but it seems logical to me.