Prevent default behavior in text input while pressing arrow up

To preserve cursor position, backup input.selectionStart before changing value. The problem is that WebKit reacts to keydown and Opera prefers keypress, so there’s kludge: both are handled and throttled. var ignoreKey = false; var handler = function(e) { if (ignoreKey) { e.preventDefault(); return; } if (e.keyCode == 38 || e.keyCode == 40) { var pos … Read more

How to change the text color of first select option

If the first item is to be used as a placeholder (empty value) and your select is required then you can use the :invalid pseudo-class to target it. select { -webkit-appearance: menulist-button; color: black; } select:invalid { color: green; } <select required> <option value=””>Item1</option> <option value=”Item2″>Item2</option> <option value=”Item3″>Item3</option> </select>

Why does my “oninvalid” attribute let the pattern fail?

If you set a value with setCustomValidity() then the field is invalid. That is setting a non-zero length string causes the browser to consider the field invalid. In order to allow for the effects of any other validations you have to clear the custom validity: <input type=”password” name=”user_password_new” pattern=”.{6,}” required oninvalid=”setCustomValidity(‘Minimum length is 6 characters’)” … Read more

Is it possible to prefill a input() in Python 3’s Command Line Interface?

If your Python interpreter is linked against GNU readline, input() will use it. In this case, the following should work: import readline def input_with_prefill(prompt, text): def hook(): readline.insert_text(text) readline.redisplay() readline.set_pre_input_hook(hook) result = input(prompt) readline.set_pre_input_hook() return result

How to finish sys.stdin.readlines() input?

For UNIX based systems (Linux, Mac): Hello, you can type : Ctrld Ctrld closes the standard input (stdin) by sending EOF. Example : >>> import sys >>> message = sys.stdin.readlines() Hello World My Name Is James Bond # <ctrl-d> EOF sent >>> print message [‘Hello\n’, ‘World\n’, ‘My\n’, ‘Name\n’, ‘Is\n’, ‘James\n’, ‘Bond\n’] For Windows : To … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)