Jaya Prakash

Jaya Prakash

  • 523
  • 2.2k
  • 51.4k

dropdown based selection validation

Feb 22 2023 11:26 AM

If Select phone number the 1st textbox should validate like only numbers are allowed and min and max are 10 digits

if i click on email again the 1st textbox  should validate regex how to do it in  asp.net combining in js pls help me

 

This is in Source  page

function isVliadUserInput() {
    var mobNo = document.getElementById("<%=DropDownList1.ClientID%>");
    var txtBox = document.getElementById("<%=TextBox1.ClientID%>");
    var id = mobNo.value;
    var txt = txtBox.value;
    if (id == "Phone Number" && txt == /^[6-9]\d{9}$/) {
        return "";
    }
    else {
        alert("Phone No Should be Min 10 and max 10 and should start with 6,7,8 or 9");
    }
    if (id == "Email" && txt != /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/) {
        alert("Email format should be: [email protected]");
    }
    else {
        return "";
    }
}

 


Answers (1)