javascript - Required field only if condition is met -
i have form with, among other fields, picture user upload , hidden field hold id. need picture required if id empty, otherwise user editing, there picture in there. can done html only? maybe done javascript, how show default popup (shown below) appears when set required ? i've checked this , this questions, don't provide expected result. popup: any ideas? to set 'popup', need call htmlselectelement.setcustomvalidity() on element. var foo = document.getelementbyid("foo"); // check condition foo.setcustomvalidity("a custom message popup"); the code found here helped me figure out.