Validating Dropdownlist using Javascript

Using Javascript:


<script type=”text/javascript”>
function Dropdownvalidation(source, args)
var DDL2 =

var country =

if (country == “0”)
args.IsValid = false;
args.IsValid = true;



<asp:DropDownList ID=”DropDownList2″ runat=”server” Height=”23px” Width=”131px”>
                    <asp:ListItem Value=”0″>—-Select—-</asp:ListItem>
                    <asp:ListItem Value=”10″>Cash</asp:ListItem>
                    <asp:ListItem Value=”11″>Check</asp:ListItem>
                    <asp:ListItem Value=”12″>Western Union</asp:ListItem>
                    <asp:ListItem Value=”13″>Credit Card</asp:ListItem>
                    <asp:ListItem Value=”14″>PayPal</asp:ListItem>
                    <asp:ListItem Value=”15″>Non-electronic Payment (Money Order)</asp:ListItem>
                <asp:CustomValidator ID=”CustomValidator1″ runat=”server”
                    ClientValidationFunction=”Dropdownvalidation” ControlToValidate=”DropDownList2″
                    ErrorMessage=”Please Select*”></asp:CustomValidator>


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s