Country as required field – problem

  • Chuck
    Chuck
    Newbie
     
    69 points

    I’m looking to require the user to select the country in order to register on my site.

    I made a required field for “Country” on the account registration page and made it a required field using a dropdown box.

    However, the problem is when you go the the registration page, instead of the dropdown box showing blank or “Choose country…”, that dropdown box is already populated with the first country on the list which happens to be Afghanistan.

    So technically, the user can skip it or forget to select their country and just submit their registration since a country is already selected and they won’t get an alert to select a country. So technically, even though it’s a required field, it won’t act like one so technically it really isn’t a required field. lol

    How do I make it so that the dropdown box is either blank or shows “Choose country…” so that if they forget to select a country, the form will spit back an alert message telling them to select a country?


    Josh
    Josh
    Super Guru
     
    13,256 points

    Hello Chuck,
    We can use a code to add a blank option.Please provide url


    Chuck
    Chuck
    Newbie
     
    69 points

    Hey Josh, thanks for the reply.

    Right now I’m, just testing out the PP Comp Theme on a subdomain http://comp.securenetpages.com/


    Chuck
    Chuck
    Newbie
     
    69 points

    Just wondering what that code is? BTW: Don’t mean to rush. Just wondering.


    Josh
    Josh
    Super Guru
     
    13,256 points

    Hello Chuck,
    Please check now.
    Code used:

    <script>
    jQuery(".field_wrapper >select option:first-child").before('<option value="1"></option>');
    jQuery(".field_wrapper >select option:first").attr('selected','selected');
    </script>


    Chuck
    Chuck
    Newbie
     
    69 points

    Thanks Josh. Works fine! I appreciate the help!


    Josh
    Josh
    Super Guru
     
    13,256 points

    You’re welcome Chuck :)


Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.