Force a user to write the first number (html) - html

I have a field for phone number but i dont want users to put like +1 but instead to write the local number .
How can i make the number to start with 6?
this is the input : how can i disable the +1 nor

If I've understod this correctly then you just might wanna add a placeholder as an element to the input, stating the user to type the local number. Another solution might be to add a value to the input. Both very simple things to add if it's the desired outcome.
<input type="text" placeholder="Write local number"/>
<input type="text" value="6"/>
Example to the two solutions:
JSfiddle

I used a minimum and maximum to make sure the phone number is correct. thanks.
so practically is kinnda the same as what i was wanting
This is what i used:

Related

Regex number pattern and maxlength not working on IE

Number pattern and max length are not working on IE.
I have tried variations of the below HTML, though IE appears to bypass that validation.
<input id="phone" maxlength="10" minlength="10" pattern="[0-9.]+" type="text">
Any suggestions on enforcing the above on IE?
The goal is to only allow 10-digits for that input field.
You can use an <input type="tel"> element, but it actually allows you to enter any characters. So, ultimately you need to specify a pattern and be very explicit as to what you are looking for and rely on HTML5 form validation. For example, if you are trying to input a phone number of the format 999.999.9999, then you want a something like the following. If you enter something that does not match the pattern and try to submit the form by hitting enter, you will get an error indication. Of course, use whatever pattern you want. If you just want digits and decimal points in any order (why?) but they must be length 10, then use pattern="[0-9.]{10}".
<form>
<input type="tel" pattern="[0-9]{3}\.[0-9]{3}\.[0-9]{4}" required>
</form>

Simple Input with Number [duplicate]

I'm working with angular 4.3, I have an input field with input type number. I'm trying to restrict the user from entering any characters/letters. However, input type number is not fully supported and allows me to enter characters such as "ABCDEFG" within the input field. What would be the best approach to restrict letters?
<input type="number"/>
If number doesn't work, I usually suggest to go for <input type="text" pattern="\d+"/>.
You can of course change your pattern to anything number-related (like (\d|[1-5]\d|60) to set min to 0 and max to 60)

Input type="number" with not mandatory step attribute

I have an input in my form with a step defined to 3:
<form>
<input name="surface" id="surface" type="number" step="3" />
</form>
I would like to be able to enter a number not multiple of the step, but it's refused at validation by the browser.
In example, if I insert "2.5" in the input, the message error I've got is:
Please select a valid value. The 2 closest values are 0 and 3.
Is it possible to make this step not mandatory?
I've tried to add novalidate="novalidate" as attribute but it doesn't work.
After more research, it appears it's not possible to make the step non mandatory on an HTML5 input.
I'll have to implement a custom number input (in jQuery or else) to achieve this.

HTML submit multiple values through one check box?

Hello I have a form that allows the user to check as many options as they like and then hit submit. Is there any way to have the input type 'checkbox' submit more than one value?
For example right now I have:
<input type="checkbox" value="testuser">
But I want something like:
<input type="checkbox" value="testuser" valuetwo="1">
Is there any way to achieve this second option?
Thanks!
Since there is no way to submit to values, is there a way to submit them both in value one?
For example:
<input type="checkbox" value="testuser,1">
And if so how would I separate the value into two?
From your comments, it sounds like you have some JavaScript that handles the data before it's submitted. If that's the case, you can add a data attribute to the checkbox. To use your example, you could call it data-valuetwo.
<input type="checkbox" value="testuser" data-valuetwo="1">
Then, your JavaScript can use getAttribute to retrieve the value in your data-valuetwo attribute and handle it appropriately. It could look something like this:
var valuetwo = checkbox.getAttribute("data-valuetwo");
I found a way to do this without JavaScript or Libraries using a hidden form-field instead:
<input name="selectedValue" type="hidden" value="defaultValue">
<input name="selectedValue" type="checkbox" value="secondValue">
Now, if the checkbox is not selected, the hidden value is sent, if it is selected, the hidden value is overridden.
You might try alternative using select2, see: https://select2.github.io/examples.html (Tagging support, use two options limit). Again, there is no enough information supplied to fully satisfy Your question.
Another approach with select box and JSON is Can an Option in a Select tag carry multiple values? (can be rewritten for checkbox)

Change the Increment Value of HTML Number Input - Decimals

Is there any way to change how much a number is incremented when using the up/down arrows on a HTML number input form?
<input type="number" step="any" value="0.00000000"></input>
I'm working with tiny numbers, it would be nice if the up/down arrows incremented just 0.00000001 at a time, instead of a whole number.
0.00000000
0.00000001
0.00000002
0.00000003
Instead of
0.00000000
1
2
3
I doubt very much if there is an easy way to do this, just though I'd ask and see if anyone else has a workaround or method as I'm sure many people experience a similar issue.
Thanks,
The step attribute is for this. Your code now has the value any, which means that any values are accepted and the step size is the default, 1. Replace it by a specific number to set the granularity and the step size. Example:
<input type="number" step="0.00000001" value="0.00000000">
Note: The end tag </input> is invalid in HTML syntax for HTML5. In XHTML syntax it is allowed, but “self-closing tags” are recommended instead of it, e.g. <input type="number" step="0.00000001" value="0.00000000" />.