The problem is that, to have the data submitted in a 'nice' format to the server, the function returns an array containing all the selected checkbox values. Again, we can make the code a lot simpler in supporting browsers: suffix tells a server side script such as PHP to accept multiple values with that name into an array.
Normally you would modify this so that you could submit or not submit the form based on the number of items selected. Note that in this section we've been using the new ES6 syntax which may not be available in all browsers.
When the user deletes what they have typed in then the other textboxes must be enable. I can only achieve this when the control losses focus using onchange event.Most modern browsers now support HTML5 Form Validation making it possible to validate form elements without (or before) any Java Script is triggered.The value of a text input box (or a textarea or password input) is available using the syntax that tells you which option has been selected.The illustration below shows this relationship: Note that the 'I' in selected Index needs to be capitalised - Java Script functions and variables are always case-sensitive. Read more about the humble checkbox in our HTML5 Checkbox Validation article.Radio buttons are implemented as if they were an array of checkboxes.
To find out which value (if any) has been selected, you need to loop through the array until you find which one has been selected: defines a locally scoped variable.