javascript - Restrict number of input in a form when selected in a select dropdown -
javascript - Restrict number of input in a form when selected in a select dropdown -
i wondering how restrict number of input using maybe javascript/html (form validation) when selected select input. scenario: have first dropdown box can take country code mobile number; 1 time selected, ofcourse 1 must input mobile number (length of mobile number depending on country code have chosen, e.g. +63[philippines] , users mobile number must 11 characters long). next line of codes:
<div class="input-append"> <select name="mobile" tabindex="15" style="height: 30px; width: 80px;" required> <option <?php if (isset($source) && $source=="philippines") ?>>+63 (philippines)</option> <option <?php if (isset($source) && $source=="america") ?>>+1 (america)</option> <option <?php if (isset($source) && $source=="uk") ?>>+44 (united kingdom)</option> <option <?php if (isset($source) && $source=="japan") ?>>+81 (japan)</option> <option <?php if (isset($source) && $source=="korea") ?>>+82 (korea)</option> <option <?php if (isset($source) && $source=="china") ?>>+86 (china)</option> </select> <input type="number" name="mobile_phone" tabindex="16" style="height: 30px; width: 127px;" placeholder="enter mobile phone number" maxlength="11"required> </div>
thankyou kind responses!
you can seek http://parsleyjs.org/doc/index.html#psly-validators-list , regular expressions:
^\+63\d{11}$ - must start +63 followed 11 digits
good luck!
javascript php html
Comments
Post a Comment