2016-10-21 126 views
0

我一直在試圖讓Knockout驗證使用至少1個字母和至少1個數字進行密碼驗證。繼承人我認爲代碼關閉,但仍然統治總是失敗。使用正則表達式驗證密碼的敲除驗證

self.Password.extend({ pattern: { message: "Password must have at least one number and one letter " }, params: "/^(?=.*[0-9]+.*)(?=.*[a-zA-Z]+.*)[0-9a-zA-Z]*$/" }); 

小號

回答

0
self.Password = ko.observable().extend({ 
    pattern: { 
     message: "Password must have at least one number and one letter", 
     params: /^(?=.*[0-9])(?=.*[a-zA-Z])[A-Za-z0-9]+$/    
    } 
});