Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

[RESOLVED] Click Button Event Always Firing

FunkySloth

New member
Joined
Aug 16, 2016
Messages
80
I'm just wondering why this alert method in Click Event always firing when I'm selecting my select element.

Code:
        $('#Register').click(function () {

            if ($('#account_type').val() == "def") {
                alert('Please select an account type.');
                return;
            }
        });


Code:
<select id="account_type" class="form-control login-type" onchange="AccountType()">
</select>
 

Shaggy Hiker

Super Moderator
Joined
Aug 6, 2002
Messages
34,844
Re: Click Button Event Always Firing

Thread moved to JQuery forum, since the language appears to be JQuery.
 

FunkySloth

New member
Joined
Aug 16, 2016
Messages
80
Re: Click Button Event Always Firing

This is the code for AccountType Function:

Code:
        function AccountType()
        {
            switch ($('#account_type').val()) {
                case "def":
                    HideContent();

                    break;
                case "app":
                    ShowContent();

                    $('#FNAME').css('display', 'block');
                    $('#MNAME').css('display', 'block');
                    $('#LNAME').css('display', 'block');
                    $('#EMAIL_ADDRESS').css('display', 'block');
                    $('#PASSWORD').css('display', 'block');

                    break;
                case "emp":
                    ShowContent();

                    $('#FNAME').css('display', 'block');
                    $('#MNAME').css('display', 'block');
                    $('#LNAME').css('display', 'block');
                    $('#EMAIL_ADDRESS').css('display', 'block');
                    $('#PASSWORD').css('display', 'block');

                    break;

                default:
                    HideContent();
                    break;
            }
        }
 

FunkySloth

New member
Joined
Aug 16, 2016
Messages
80
Re: Click Button Event Always Firing

Found the line of code that made the unusual behavior of the button click. There are two elements with the same Register id.
 
Top