freenode :: #html5

17 Jan 2017
01:48Wintershade3001Hey guys! I have a quick question. I need to write a HTML form which validates input by regex, and if the input is invalid, it has to focus back on that field. Can anyone give me any leads on that? Thanks!
01:48moo-_-Wintershade3001: HTML5 contains built-in regex validator
01:49Wintershade3001I know, I'm using it. But I don't know how to make it re-focus on the invalid field.
01:49moo-_-Wintershade3001: might be tricky
01:49Wintershade3001Do I need to use javascript for that?
01:49moo-_-Wintershade3001: and has some complicatinos
01:50Wintershade3001hm. I asked over at #javascript, didn't get any answer yet.
01:50moo-_-but automatic focus tricks are very bad for mobile user experience, because of soft keyboard popping up unwantedly
01:50Wintershade3001Ya I know. The form is hidden by default, and only pops up after clicking on a link.
01:53moo-_-Wintershade3001: I think you can use :invalid pseudoclass to find the field where the validation has failed and then just use jQuery.focus() or similar to set the focus on it
01:53Wintershade3001I'm not allowed to use jQuery for this :(
01:54moo-_-Wintershade3001: well you can naturally do same for vanilla JavaScript, just study DOM API documentation how to get it accomplsihed
01:55Wintershade3001alright, thanks :)
01:57moo-_-Wintershade3001: good luck
01:58Wintershade3001Thank you, good sir.
17 Jan 2017
Last message: 15 hours and 15 minutes ago