Input Mobile NumberField Allow Only Number and + maxlength="13"

Publish: 23 December 2023, 11:39 pm IST | Views: Page View 295

<label for="mobile">Mobile Number:</label>
<input type="text" id="mobile" name="mobile" maxlength="13" required><br>
<span id="mobileError" style="color: red; display: none;">Please enter only numbers</span><br>
<script>
document.getElementById('mobile').addEventListener('input', function() {
    let mobileInput = document.getElementById('mobile').value;
    let isValid = /^[0-9+]+$/.test(mobileInput);
    let errorSpan = document.getElementById('mobileError');
    
    if (!isValid) {
        errorSpan.style.display = 'inline';
    } else {
        errorSpan.style.display = 'none';
    }
});

</script>

Categories: Uncategorized

Share:

Related News

BPL List 2026
CRPF Constable (Sports Quota) Recruitment 2026
India Post GDS Result 2026 - Check 1st Merit List Date, Circle-wise PDF
NREGA Job Card Chhattisgarh
Cg Ration Card list