0

How to make input of number only takes 10 digit. Eg mobile number

9th May 2020, 2:44 PM
amith
15 Antworten
+ 3
maxlength="10" in input tag
9th May 2020, 2:48 PM
Abhay
Abhay - avatar
9th May 2020, 2:56 PM
Bartika🎶
Bartika🎶 - avatar
+ 3
Yes
9th May 2020, 3:15 PM
Bartika🎶
Bartika🎶 - avatar
+ 3
No😂
9th May 2020, 3:17 PM
Bartika🎶
Bartika🎶 - avatar
+ 1
amith pattern to ensure only digits, tel allow "." and other special characters
9th May 2020, 3:20 PM
Calviղ
Calviղ - avatar
+ 1
okay thanks @calvin
9th May 2020, 3:21 PM
amith
+ 1
Yes ,so I coded this but it turns to 0 if number is greater than 10 window.onload=function(){ var c=document.getElementById("num"); c.addEventListener("input",stop,false); function stop(){ a=this.value.length; if(a>10){ this.value="0"; } } } But you already got the answer and I didn't knew about that Tel thing and pattern ,so my code won't work when */ are entered
9th May 2020, 3:30 PM
Abhay
Abhay - avatar
0
max length only work for text right? @Abhay
9th May 2020, 2:53 PM
amith
0
thanku
9th May 2020, 3:12 PM
amith
0
type="Tel" is enough right? @Bartika,Calvin
9th May 2020, 3:14 PM
amith
0
without pattern also it's now got restricted to 10digits.. pattern is mandatory? @Barthika
9th May 2020, 3:15 PM
amith
0
ok thanks @Bartika
9th May 2020, 3:18 PM
amith
0
tanku bro @Abhay
9th May 2020, 4:31 PM
amith
0
It is very easy set maxlength to 10 digits like this <Input type="tel" name="tel" maxlength ="10" >
10th May 2020, 6:51 AM
𝖆𝖊𝖙𝖍𝖊𝖗
𝖆𝖊𝖙𝖍𝖊𝖗 - avatar