Only JavascriptCode... But I can understand it...
/*
* Created by: Niu Yu
* Note: You can only enter numbers in the text box. The disadvantage is that you can enter Chinese characters. Therefore, you must make a judgment when the focus is lost.
*/
$ (Function (){
// Add a keypress to the text box, that is, judge when the keyboard is pressed
$ ("# Ctl00_contentplaceholder=txtsumvalue"). keypress (function (event ){
If (! $. Browser. Mozilla ){
If (event. keycode & (event. keycode < 48 | Event. keycode > 57) & event. keycode! = 46 ){
// IE6, 7,8, opera, and chrome
Event. preventdefault ();
}
} Else {
If (event. charcode & (event. charcode < 48 | Event. charcode > 57) & event. keycode! = 46) {
// firefox
event. preventdefault ();
}< BR >});
// When the text box loses focus, check whether the input is a number.
$ ("# Ctl00_contentplaceholder=txtsumvalue"). Blur (function (){
VaR input = $ (this );
VaR v = $. Trim (input. Val ());
// Alert ("input value:" + V );
VaR Reg = new Regexp ("^ [0-9] + (. [0-9] {2 })? $ "," G ");
If (! Reg. Test (V )){
Alert ("enter a number, which can only contain two decimal places! ");
Input. Val ("0 ");
}
});
});
If you use jquery, just import jquery.