2011-12-30 84 views

回答

0

以下正則表達式匹配99.99%,99999.99等等

\$\d+\.\d{2} 

使用jQuery的.live()功能接線keyup事件到你的文本框中。

$('.textBoxDecimalOnly').live('keyup', function() { 
    // inside this keyup hook, grab the value in the text box. 
    // if it matches the regex... do something 
    // else do something different 
}); 

時KEYUP情況,覈對該正則表達式表達的文本框中的值,你希望你的答案是什麼。

,使其從右工作向左,你可以重新格式化字符串...

// 1. get text in the box. 
// 2. if length < 3 ... append a "." to the first string. 
// 3. if > 3 get the index of the 2nd to last character and append "." just before it. 

的東西,你的生活的鉤子裏的邏輯。

+0

感謝您的快速回復! – Spartanblogger 2011-12-30 21:05:26

相關問題