fixes #5820 Error in console when enable the mandatory field

Fixed the issue and pushed the code for review, please check it.