Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inputs are being entered from right to left instead of left to right on input fields of type NUMBER #45

Open
jmfortich opened this issue Oct 21, 2017 · 3 comments

Comments

@jmfortich
Copy link

Say for example I want to enter an amount of 1,293 as principal amount but it is accepted as 3,921. Also, the BKSP is not working. I already tried adding css style "direction: ltr" but to no avail. Anyone's help will be much appreciated. Thank you.

angular-keyboard issue

@reitsma
Copy link

reitsma commented Dec 14, 2017

I am not 100% sure, but I think it has to do with the support of selectionStart (see https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange, especially browser compatibility note [1]). In Chrome I detected that type email is not supported. Although I am not sure, I suspect Chrome of changing the default setting of selectionStart and selectionEnd into null. Together with the buggy implementation of the following function, the effect will be an inverse of input.

function hasSelectionStartEnd(elem) {
var hasSelection = false;
try {
hasSelection = !isNaN(elem.selectionStart) && !isNaN(elem.selectionEnd);
} catch(e) {};
return hasSelection;
}

isNaN(null) is false, isNaN(undefined) is true (of course -:)).

@marcioarp
Copy link

marcioarp commented Jun 27, 2019

Hi, I solve the problem changing this function, just adding one line (194):

	function hasSelectionStartEnd(elem) {
		//return true;
		var hasSelection = false;
		try {
			hasSelection = !isNaN(elem.selectionStart) && !isNaN(elem.selectionEnd);
		} catch (e) {
		};
		if (elem.type == 'number') hasSelection = false; //change here //line 194
		return hasSelection;
	}

@marcioarp
Copy link

marcioarp commented Jun 27, 2019

Hi, after accept number, there another problem with decimals number, then solved with:

line: 907 add:

				} else if (this.VKI_target.type =='number') {
					if (this.waitingDecimal == undefined)
						this.waitingDecimal = false;
					if ((text == ',' || text=='.')) {
						this.waitingDecimal = true;
					} else {
						if (this.waitingDecimal) {
							this.VKI_target.value += '.'+text;
							this.waitingDecimal = false;
						} else {
							this.VKI_target.value += text;
						}
						
					}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants