Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Check boxes on contact form

Featured Replies

Guy's. more help is needed on my site. I'm sure there is probably the answer already on here and is almost certainly on Google but I am having no joy in finding it or the examples I have found don't explain the specifics enough and are a little confusing. I have this contact form on this site

 

http://www.uksecurity-directory.co.uk/addyourcompany.html

 

The from works perfectly well and I get all the information but clients are getting a little confused when selecting regions. They should be selecting either UK Wide OR selecting individual regions but I'm getting people selecting almost everything. What I'm trying to achieve is making it so that if you select UK Wide, the rest of the region check boxes are greyed out/ un-selectable. But if they don't select UK Wide they still need to be able to select multiple regions. Am I right in thinking this needs to be done in JS?

 

I also want the text box lower down the page to only be available to type in if Silver is selected from the radio buttons. As with all my previous requests for help, I'm not expecting someone to just do the work for me, although it would be handy :D , but if you know of a good place to learn this type of coding, It would be appreciated.

 

As always, I thank you for your time.

You're definitely going to need JS to get the effect you want for the checkboxes and also to make the single text box editable for certain values. It's worth noting that you are going to need to validate it regardless once the form is submitted, as JScan be bypassed/disabled pretty easily and while a majority of people do use JS, not all do. As for where to learn - I see you're using jQuery which is a great library and the one I use for everything. I'd recommend using this site

http://www.learningjquery.com/

or getting the sitepoint jQuery novice to ninja eBook

  • Author

You're definitely going to need JS to get the effect you want for the checkboxes and also to make the single text box editable for certain values. It's worth noting that you are going to need to validate it regardless once the form is submitted, as JScan be bypassed/disabled pretty easily and while a majority of people do use JS, not all do. As for where to learn - I see you're using jQuery which is a great library and the one I use for everything. I'd recommend using this site

http://www.learningjquery.com/

or getting the sitepoint jQuery novice to ninja eBook

 

Thanks for your speedy reply. I shall give it a go.

  • 2 weeks later...
  • Author

Well I got the desired effect I wanted and thanks to some hints over at stackoverflow and the tutorials that Jay linked. This is what I used.

 

I added the following into my Javascript coding that I already had in place for the validation.

 

 $(document).ready(function() {
    $('.listing').change(function(){
	    if ($(this).val() == 'Bronze') {
		    $('#Description').attr('readonly','readonly');
	    } else {
		    $('#Description').removeAttr('readonly');
	    }
    });
   });

 

This didn't exactly work at first because my Bronze radio button is set to be the default with the attribute checked. What was happening was that when the page opened Bronze is selected by default but I was still able to input into the text box, unless I selected Silver, then re-selected Bronze again. I added the attribute readonly="readonly" to the text box and this has made it read only to start with until Silver is selected. All works perfectly!!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.