2010-10-22 22 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

相關問題