Changed the method of hide and show the dependent elements and error fixed