Jump to content
rizwansyed

two script files

Recommended Posts

Hi

I have a code in which i am running a script for drop-down list to show only the selected drop-down content as shown in attached file.

I need to add one more script file for alerting a warning for unselected  drop-down list as shown below

<input type="submit" value="submit" onclick="return Validate()" />
<script >
    function Validate() {
        var abc = document.getElementById("opts");
        if (abc.value == "") {
            //If the "Please Select" option is selected display error.
            alert("Please select an option!");
            return false;
        }
        return true;
    }
</script>
 
How can i merge two script files or anyway to call both files
 
Please suggest
 
Thanks and Regards
Rizwan Syed

adding one more script file.txt

Share this post


Link to post
Share on other sites

Thanks for the reply.

I didnt get exactly what u mean to say but i tried 

                        <form action="/action_page.php" method="post" autocomplete="off" onsubmit="Validate()">
with two script files but didnt get it work.

 

Can you just explain once again

Share this post


Link to post
Share on other sites

Placing onsubmit on the form element ONLY! Will capture ALL form submission achieved by clicking any button that acts like a type submit, or a non 'required' input/s where a user will press the keyboards 'Enter' key while in the input, that will trigger a submission event. So to properly validate using a validation function whenever a submission occurs it should run by the onsubmit event that is always applied to the form element and nowhere else.

Edited by dsonesuk

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×