I am making a website and one of the requirements is it to be IE8 compatible. I have a simple form on my page and using a radio button I am changing what fieldsets of the form are visible. Basically I am giving user an option to either input his name or his number. I am using IE11 on W10 in IE8 compatibility mode in F12 menu and the switching is not working. It works everywhere else, even in IE9+. Do you know what could be the problem?
Both my radio buttons have an onclick function that set one fieldset at display:none and the other at display:block. The "header__form__fs_person" is hidden by default.
html:
<form class="header__form" name="form_name">
<fieldset class="header__form__label_choices">
<label class="header__form__label" for="person">Podle jména</label>
<input class="header__form__input_radio" type="radio" value="person_on" id="person" name="choice" onclick="hideIc(this)" checked>
<span class="header__form__divider">/</span>
<label class="header__form__label" for="ic">Podle IČ</label>
<input class="header__form__input_radio" type="radio" value="ic_on" id="ic" name="choice" onclick="hidePerson(this)">
</fieldset>
<fieldset class="header__form__fs_person">
<input class="header__form__input_text" type="text" id="name" placeholder="Jméno" required>
<input class="header__form__input_text" type="text" id="lastname" placeholder="Příjmení" required>
<input class="header__form__input_text" type="text" id="bday" placeholder="Narozen" onfocus="(this.type='date')" required>
</fieldset>
<fieldset class="header__form__fs_ic" disabled>
<input class="header__form__input_text" pattern=".{9,}" placeholder="123456789" required>
</fieldset>
<label class="header__form__terms" for="terms">Souhlasím s <a class="header__form__terms_a" href="">obchodnimi podmínkami</a></label>
<input class="header__form__input_checkbox" type="checkbox" id="terms" required>
<input class="header__form__input_btn" type="submit" value="Ověřit">
</form>
js:
<script>
function hideIc(radio_btn) {
if (radio_btn.checked) {
var ic = document.getElementsByClassName("header__form__fs_ic");
var person = document.getElementsByClassName("header__form__fs_person");
for (var i=0; i < ic.length; i++) {
ic[i].style.display = "none";
ic[i].disabled = true;
person[i].style.display = "block";
person[i].disabled = false;
}
}
}
function hidePerson(radio_btn) {
if (radio_btn.checked) {
var ic = document.getElementsByClassName("header__form__fs_ic");
var person = document.getElementsByClassName("header__form__fs_person");
for (var i=0; i < ic.length; i++) {
ic[i].style.display = "block";
ic[i].disabled = false;
person[i].style.display = "none";
person[i].disabled = true;
}
}
}
</script>