开发者

Validate dropdownlist selectedvalue against a list from static property

I am using javascript to validate user input on my aspx page. I am easily able to validate textboxes and dropdown list for differenet scenarios.

Now, on one of my dropdown lists (for country), I need to check if it is an allowed country or not for a particular service. I have stored the valid country list in a static property. Is there a way to validate my dropdownlist selected value against that static property?

Any help would be much appreciated.

Cheers, Abhi.

function validateService(source, args) 
{
 开发者_JAVA百科           var country = document.getElementById('<%= ddDestCountry.ClientID %>');
            var service = document.getElementById('<%= ddService.ClientID %>');
// Get allowed country list from my static class
            var countryList = document.getElementById('<%= StaticProperties.EUCountryList %>');

            if (service.value == "P") 
            {
               // I want to do something like this
                if (!countrylist.Contains(country.value)) 
                {
                    args.IsValid = false;
                }
                else {
                    args.IsValid = true;
                }
            }
            return;
        }

Update(Additional Information): The static property is read-only so it cannot be tampered with from the page.


This validation should be done on the server side and not on the client side. there's nothing preventing me from using greasemonkey to change your static list while I have your page up and inserting "Oz" as a country in your "validating" list

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜