How to set binding mandatory for Imagebutton in javascript

I have a field like Image. I want to set it mandatory for the buttonclick event in javascript.

Here is my html

<input type="image" name="ImgAttach" id="ImgAttach" src="../Images/attachment_1.png" onclick="return Imgclick();" />

and button code

<input type="submit" name="CmdSave" value="Save" onclick="return FunSaveValidate();" id="CmdSave" class="button" />

Note I want this in javascript.

See js fiddle for more details

+4
source share
2 answers

<input type="image">used to submit the form (similar <input type="submit">), and not to attach image files ( https://www.w3.org/TR/html5/forms.html#image-button-state-(type=image) )

To attach image files and make this a required field , use<input type="file" accept="image/*" required>

+1

<input type="file" accept="image/*" required> <input type="image"> .

<input type="image">

JS

+1

Source: https://habr.com/ru/post/1653396/


All Articles