2010-10-22 47 views
0

我有这个安全问题答案输入字段验证函数,我想确保字符串转换为小写,以防用户在第一个输入答案现场,并在第二场小案例:我想使用Dojo使我的输入字符串小写

validate : function(){ 
//check if both input fields are not blank 
//if not blank, check to see if they match and send back status message 
var _inputs = dojo.query("#" + this.id + " input"); 
var _y = "" 
var _matchingValues = []; 
_this = this; 
for(var i = 0, len = _inputs.length; i < len; i++) { 
    _matchingValues.push(_inputs[i].value); 
} 
dojo.forEach(_matchingValues, function(arr) { 
    if (arr == "") { 
    _this.status = "incomplete"; 
    //_this.status = "invalid"; 
    return _this.status; 
    } 

    else if (arr != _y) { 
    _y = arr;     
    _this.status = "nomatch"; 
    return _this.status; 
    } 

    else if (arr.length < 3){ 
    _this.status = "short"; 
    return _this.status; 
    } 

    else { 

    _this.status = "valid"; 
    return _this.status; 
    } 
    }); 
}, 

这怎么可能完成

回答

1
_matchingValues.push(_inputs[i].value); 

你可以改变这种做法,你执行你比较之前只推小写值。

_matchingValues.push(_inputs[i].value.toLowerCase()); 
+0

这在我重建了dojo配置文件后生效 – Amen 2010-10-25 15:13:51

相关问题