gfranco
asked on
Drop Down list validation using Java Script in ASP.NET VB.NET
Hi,
I need to have a validate function that allow me to identify elements (different drown list) when they were not selected.After being called by validate function Thanks for your help
I need to have a validate function that allow me to identify elements (different drown list) when they were not selected.After being called by validate function Thanks for your help
<script>
function validateDDList(ctlname,ddlctl)
{
if (ddlctl.value.index == 0) {
alert(ctlname + ' Select at least one option from the list');
ddlctl.focus();
return false;
}
return true;
}
</script>
function validate() {
if(!validateDDListt('Select at least one list from y ',<%= ddEntityCountry.ClientID %>))
return false;
Could you plz explain the que a bit more
ASKER
Sure, I have 3 drop down list country state and city, I want to use a function that assure user to pick a record for each drop down. This function I am planning to use on master page since I have other pages to validate. So the function enforce the selection and avoid no values on submission. The message will be generic upon depend on combo selection
The form is being called at the end of wizard template finish button. Hope this helps
I hope this clarify
The form is being called at the end of wizard template finish button. Hope this helps
I hope this clarify
Did you try using built-in asp.net RequiredFieldValidator: http://www.c-sharpcorner.com/blogs/5385/asp-net-dropdownlist-validation-using-required-field-validat.aspx
or you only want to do it via javascript?
http://jquerybyexample.blogspot.com/2012/07/validate-aspnet-dropdownlist-using-jquery.html
or you only want to do it via javascript?
http://jquerybyexample.blogspot.com/2012/07/validate-aspnet-dropdownlist-using-jquery.html
ASKER
Thanks field validate is not an option I am trying to use the same function for all of them thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.