Search This Blog

11 February 2014

How to check if at least one field is set in a form before submiting using JQuery

I have a form with many fields (Textbox, Listbox, Checkbox, Radio Button, File box, Text Area) in my PHP page. When submitting the form, I need to check at least one field must be set. If it’s not I don’t want to submit the form. The form is having lots of control, so it’s not a good idea to go through each control to check if a value is set. So here is a JavaScript function which will make the job very easy.