i have a form like this: Please how can I valid this form using javascript so that only jpg files are uploaded. thanks for reading. Answer You can bind the onsubmit event of your form, and check if the value of your file input ends with “.jpg” or “.jpeg”, something like this: Check the above example here.