0

i want to validate my mobile number field with regular expression in jQuery. here is some example i want for validation

(+91)9876543210 (+97)83450635

how to implement it with regular expression or any other way i have tried this, this is working fine but its not allow me to type '+', so i want to go with regular expression.

$("#number").keydown(function (e) {
            if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
                (e.keyCode == 65 && ( e.ctrlKey === true || e.metaKey === true ) ) || 
                (e.keyCode >= 35 && e.keyCode <= 40)) {
                     return;
            }
            if (((e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105) && (e.keyCode != 41) && (e.keyCode != 40) && (e.keyCode != 43)) {
                e.preventDefault();
            }
        });
  • Its just adding of round brackets buddy!! You have 85-90% of answer there.. You just need extra brackets to that regular expression.. Thats how you learn.. No Offense meant.. Try this then `^\(+[1-9]){1}[0-9]{3,14}$` – Guruprasad J Rao Oct 06 '15 at 06:44
  • So it worked right? and FYI I haven't downvoted your question... – Guruprasad J Rao Oct 06 '15 at 06:50

0 Answers0