Answer the question
In order to leave comments, you need to log in
How to implement text field validation?
There is a text field:
<input id="phone" type="text" autocomplete="off" class="telephone" value="Введите Ваш номер" name="input" >
<button id="enter" class="entr btn" disabled type="submit">Enter</button>
function checkParams() {
var phone = $('#phone').val();
if(phone.length !== 12 ) {
alert("ne12")
$('#enter').removeAttr('disabled');
} else {
alert("12")
$('#enter').attr('disabled', 'disabled');
}
}
.on('input', function () {
Answer the question
In order to leave comments, you need to log in
In theory, you need to climb to the server, compare it with the database of mobile numbers and return the desired operator. It's in theory. In practice - On the one hand, everything is decided by the operator code in 3 digits and the base of the Ministry of Communications describing which numbers were issued to which operator, and on the other hand, we have the opportunity to change the operator without changing the phone number (and if you do not have access to up-to-date data - checking the operator code will cause an error), and we also have such an operator as "Hello incognito", whose subscribers may look like a Moscow landline phone or MTS / Megafon / Beeline, but not be them. In my opinion, you need to collect a small database of 4-digit numbers (operator code + 1 first digit of the number) Based on these data, find out if you belong to a certain operator according to the Ministry of Communications, offer the user this operator,
PS do not forget that Javascript can be disabled.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question