在C#

时间:2019-04-23 06:08:46

标签: c# model-view-controller

这是我的控制器代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CaptchaMVC5.Models;
using CaptchaMvc.HtmlHelpers;

namespace CaptchaMVC5.Controllers
{
    public class CaptchaController : Controller
    {
        // GET: Captcha
        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Index(Registration Registration)
        {
            // Code for validating the Captcha  
            if (this.IsCaptchaValid("Validate your captcha"))
            {
                ViewBag.ErrMessage = "Validation Messgae";
            }
            return View();
        }
    }
}

我必须在验证码代码中添加验证。

验证码中有一个小写字母,那么如果我们输入小写字母,则必须接受,否则不接受。

如何验证验证码是否区分大小写?

1 个答案:

答案 0 :(得分:0)

这不是很大的变化。只需修改IsCaptchaValid函数并检查字符串大小写,如下所示

 static bool IsCaptchaValid(string captchatext)
    {
        if (captchatext.Any(char.IsLower))
        {
            //your logic
            return true;
        }
       return false;
    }
相关问题