根据当前线程文化进行Jquery货币验证

时间:2015-09-30 06:50:35

标签: c# jquery

我正在控制货币,我在下拉列表中提供货币类型列表,当用户在下拉列表中选择货币时。文本框(货币)验证应该根据该货币进行验证,如果未选择下拉列表中的任何类型,则应根据当前文化进行验证。

enter image description here

我执行此服务器端的代码是

 protected override void OnLoad(EventArgs e)
    {
        // take currency Info using currency code which is given by user

        foreach (var culture in GetCultureInfosByCurrencySymbol(this.CurrencyISOCode))
        {
            Console.WriteLine(culture.Name);
            System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture.Name);
            currentCulture = CultureInfo.CurrentUICulture;
            cultureCurrencySymbol.Text = currentCulture.NumberFormat.CurrencySymbol;

            RegionInfo currentRegion = new RegionInfo(currentCulture.ToString());
            cultureCurrencyCode.Text = currentRegion.ISOCurrencySymbol;
        }
    }

    /// <summary>
    /// Validating currency Entered by User
    /// </summary>
    /// <param name="source"></param>
    /// <param name="args"></param>

    private void ValidateCurrencyFormat(object source, ServerValidateEventArgs args)
    {
        if (currencyTextbox != null)
        {
            decimal num;

            bool isValid = decimal.TryParse(currencyTextbox.Text,
                                          NumberStyles.Currency,
                                          currentCulture,
                                          out num);

            args.IsValid = isValid;
        }
    }

CurrencyISOCode是我从标记中获取价值的属性。

如何在jQuery中进行此验证?

0 个答案:

没有答案