how to set required field in javascript code example
Example 1: javascript add required to input
element.setAttribute("required", "");
element.removeAttribute("required");
Example 2: javascript add required attribute to input
element.setAttribute("required", "");
element.required = true;
jQuery(element).attr('required', '');
$("#elementId").attr('required', '');
element.removeAttribute("required");
element.required = false;
jQuery(element).removeAttr('required');
$("#elementId").removeAttr('required');
if (edName.hasAttribute("required")) { }
if (edName.required) { }