本文介绍了jQuery validate-如何忽略字母大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能是一个愚蠢的问题,但是我似乎在Google土地上找不到任何东西.我只需要一种方法来忽略输入字段的大小写.我正在进行城市名称匹配,但是需要同时使用"Atlanta"和"atlanta".我应该如何编辑它以获得我需要的验证爱?

Probably a goofy question, but I can't seem to find anything in google land. I simply need one of my methods to ignore the case of the entered field. I am doing a city name match, but need both "Atlanta" and "atlanta" to be valid. How should I edit this to get the validation love that I need?

    jQuery.validator.addMethod("atlanta", function(value) {
    return value == "Atlanta"; //Need 'atlanta' to work too
}, '**Recipient must reside in Chicago City Limits**');

首先感谢所有:)

推荐答案

jQuery.validator.addMethod("atlanta", function(value) {
    return value.toLowerCase() == "atlanta"; 
}, '**Recipient must reside in Chicago City Limits**');

这篇关于jQuery validate-如何忽略字母大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 05:31