Get highlighted input value - html

is there a way to get an input value and retrieve if the value is highlighted?
I've a simple input:
<input type="text" id="myId" [(ngModel)]="myModel" (keypress)="myNumberInput($event)" min=0 max=99999/>
I'd should know throw event if the value in the input is highlighted. For example:
enter image description here
Is it possible to get this information in event?
Thanks
PS. I'm developing in Angular 2 so I need to do this without using jQuery.

This is working for me :
<input type="text" id="myId" [(ngModel)]="myModel" (select)="myNumberInput($event)" min=0 max=99999/>

Related

The autofill field name “postal-code” is not allowed in this context

im currently trying to optimize my forms on my Webpage. The HTML Validator gives me the following error:
The autofill field name “postal-code” is not allowed in this context.
I dont know why, since it does what it should. The autofill inserts the Postal-code. Here is the Element:
<td><input type=number name="changeZip" min=00000 max=99999 autocomplete="postal-code"></td>
This Element has same Error:
<input class="login" type="number" name="txtZip" value="" required max="99999" min="00000" placeholder="Postleitzahl" autocomplete="postal-code"/>
Why isnt it allowed here according to the Error-Message? I dont find anything in Google for this.
Thanks.
The type attribute needs to be "text". Some countries use a combination of letters and numbers for their postal code.
Therefore, your input element should be
<input type="text" name="changeZip" minLength="5" maxLength="5" autocomplete="postal-code">

Why the value form <input> is copied to all another inputs?

this is part of my code:
<input style="width:100px;" #quantity name="vehicle{{i}}_quantity"
class="options-input" [(ngModel)]="detail.quantity" type="number" required [ngClass]="{ 'error-bottom-border': quantity.value.length==0}" placeholder="0" min="0" [disabled]="viewMode">
When I put a value to one of the inputs all others get the same value. I dont't want this. I tried to add:
[ngModelOptions]="{standalone: true}"
But still nothing. Every input has uniqe name.
I hope that is a simple case.
ALL CODE
http://pasted.co/85f3a46b
did you use same ngModel for all the input? if yes that's the problem .Ngmodel is used to bind data to the input .

Text to the right after blinking cursor inside input tag

I don't know what to search for. But I want to style my input first of all it display a help text with placeholder for example:
<input class="form-control input-lg" id="id_username" maxlength="30" name="username" placeholder="Enter your blog domain" type="text">
Edit: But when the user click on it and enter a value I want to display .domain.com right after the blinking cursor. How could I do that?
You can use setSelectionRange for your purpose.
$(".input-lg").click(function(){
if($(this).val() == "")
$(".input-lg").val(".domain.com");
$(".input-lg")[0].setSelectionRange(0, 0);
});
Here is the jsFiddle
Hope it helps :)
EDIT:
You need to check the field to make sure you don't overwrite the input field existing data every time the field is clicked.

create a label for text inputs that is diffrenet from value

for example i have a disabled input that holds a time span, but i want to show it to user in a friendly format. just like select element, the option with in can hold a value that is different from what is displayed
<select><option value=1>Label is there</option></select>
can it be done with input ?
something like
<input type='text' value='<?=$time?>' label='<?=date('c',$time);?>' />
P.s: im not asking for a place holder.
currently im doing
<label for="app_time">Time</label>
<input type="hidden" value="2013-04-27 15:40:00" name="app_time">
<input type="text" value="27 Apr 13, 03:40" Disabled>
is there any other method ?
You can wrap an input in the label tag.
<label>Text for the input <input type="text" name="yourInput"></label>
Or you can reference the input from a label tag.
<label for="yourInput">Text for the input</label>
<input type="text" name="yourInput" id="yourInput">
You can add styling to the label element and it aids people using assistive technology as it links the description with the form element.
Not in the way you are asking, however you could always try it with a hidden element holding the real value...
Try;
<input type="text" value="<?=date('c',$time);?>" name="dummytime" />
<input type="hidden" value="<?=$time;?>" name="realtime" />
So to get $time it would be $_POST['realtime'] and to get the formatted date value it would be $_POST['dummytime'].
No, not in the way you're asking. The value of the text input is what is displayed within it.
As an alternative you could use a hidden input with the actual value, and then put the label in the text input
Your best bet is to handle converting the date to a timestamp on the server side. You'll need to ensure the submitted text is able to be converted to a timestamp, however, and show the user an error if not. There is not a built-in way for JavaScript to convert some given user-inputted string to a computer-readable date format.
Edit: I'm assuming you want the actual value to match whatever the user enters, not a static timestamp. If you want to submit a static value regardless of the user's input, simply use a hidden input (<input type="hidden">) and a secondary text input that you can ignore.

Input box how to stop input?

I have a HTML page.
I want to have a input box, that has a default value, that people can select, but not write over. It if for a share link to the page.
How can I do this?
EDIT: Using readonly="readonly" works and satisfies the solution, but the mouse pointer becomes a stop sign. I have chosen to use pure text instead of putting the share link into an input box. A javascript/Jquery solution will be possible but I don't use scripts on my website.
give input box readonly property like
<input type="text" id="a" value="abc" readonly="readonly" />
you can use it as
<input type="text" id="a" value="abc" disabled="true"/>
you can also dynamically change this attribute using javascript as per your requirement.
add
readonly="readonly"..........
please notice :
readonly - is a markup class
we dont have to write x=x
so we can only write x
hence
<input type="text" id="a" value="abc" readonly />
also work
Method 1
input type="text" id="a" value="abc" disabled="true"
Method 2
input type="text" id="a" value="abc" readonly="readonly"
In first case, text field will be disabled and you will not be allowed to select the value, where as in the second method you can select it, but not able to edit it..
Disabled field are not accessible in successor pages.
You can also dynamically change this attribute using javascript as per your requirement.