Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

Checking if one field is populated, the other 2 are as well

I think i need to use if-else for this but maybe there's a better way of doing this.

I have a fax number field...divided in 3 fields. Fax is NOT a required but still, i dont want users to enter something 999 99 (incomplete data).

How can i check that if , for example, area code is filled, the other 2 fields are also populated?

I do use a regularexpressionvalidtor to check for length of fields.
<tr>
        <td width="137"><label for="fax">Fax number:</label></td>
        <td width="310">
    (<input type='text' name="fax1" id="fax1" runat="server" class='autotabindex' tabindex="11" maxlength="3" style='width:12%'/>)
    <input type='text' name="fax2" id="fax2" runat="server" class='autotabindex' tabindex="12" maxlength="3" style='width:12%'/>
    <input type='text' name="fax3" id="fax3" runat="server" class='autotabindex' tabindex="13" maxlength="4" style='width:20%'/>
    </td>
        <td width="280">
        <span class="feedback">
        <asp:RegularExpressionValidator ID="RegularExpressionValidator11" runat="server" ControlToValidate="fax1" ValidationExpression="^[0-9]{3}$" ErrorMessage="Invalid!" Text="Invalid!"></asp:RegularExpressionValidator>
          <asp:RegularExpressionValidator ID="RegularExpressionValidator12" runat="server" ControlToValidate="fax2" ValidationExpression="^[0-9]{3}$" ErrorMessage="Invalid!" Text="Invalid!"></asp:RegularExpressionValidator>
          <asp:RegularExpressionValidator ID="RegularExpressionValidator13" runat="server" ControlToValidate="fax3" ValidationExpression="^[0-9]{4}$" ErrorMessage="Invalid!" Text="Invalid!"></asp:RegularExpressionValidator>
         </span>
        </td>
      </tr>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Camillia

ASKER

How can I do it with Javascript? what should i google for?