html - html5 "required" attribute for mixed radio/text -
i'm designing form has, among others, following elements:
<div> <div class="radio-list"> <label><input type="radio" name="ftp_directory" id="ftpdir_public_html" value="public_html"> <strong>public_html</strong> directory</label> <label><input type="radio" name="ftp_directory" id="ftpdir_blank" value="."> <strong>root</strong> directory </label> <label><input type="radio" id="ftpdir_custom" value=""> other directory (please specify)</label> </div> <input name="ftp_directory" class="form-control" type="text" disabled="disabled" aria-disabled="true"> </div>
i enable latter <input>
text element when check 3rd radio (via jquery) , fine.
what want set required
attribute in correct way vaildates if of first 2 radio button checked or 3rd radio checked , input
has text.
note: know can js/jquery validation code i'd in pure html5.
as said, cannot radio buttons + text input. however, can achieve similar data lists , single text field:
<input type="text" name="ftp_directory" list="preselection" required> <datalist id="preselection"> <option>public_html</option> <option value=".">current directory</option> </datalist>
logically, meets constraints. however, might not stylistically you're looking for.
Comments
Post a Comment