sorry i know this question might duplicated but i'm really bad in regex, hope someone could help to fix it. How i can apply this regex in my javascript. Any help will be appreciated.
^6?01\d{8}$
My current coding.
function phoneNumber()
{
var mobile = document.mainform.HP_NO.value;
//need condition here if phone number does not match with the regex given
alert("Not a valid Phone Number.");
document.mainform.HP_NO.value = "";
document.mainform.HP_NO.focus();
return false;
///
return true;
}
<input type="text" class="input-name" name="HP_NO" placeholder="e.g (60121234567)" onblur="if(value=='') value = '';phoneNumber();" onfocus="if(value=='') maxlength="11" onPaste="return false"/>