In some cases, you need to restrict only certain characters in the text box (the tedit control here) in the program. For example, you can only enter numbers. In this case, you can set the numbersonly attribute of tedit to achieve this. Here, tedit is limited to only 0 to 9 characters. If you want to restrict the number of decimal places, the decimal point is blocked. Therefore, the numbersonly attribute cannot be used, and no other attribute can be implemented. You have to do it yourself! Restrict input, which can be done in the onkeypress event. See the following code:Procedure tform1.edit1keypress (Sender: tobject; var key: Char); var EDT: tedit; STR: string; strl: string; strr: string; begin // get the current text content, note that the selected part should be removed (because it will be rewritten ). EDT: = tedit (sender); STR: = EDT. text; If length (EDT. seltext) <> 0 then begin strl: = leftstr (EDT. text, EDT. selstart); strr: = rightstr (EDT. text, length (EDT. text)-EDT. selstart-EDT. sellength); STR: = strl + strr; end; // restrict the input number/decimal point/backspace key if not charinset (Key, ['0 '.. '9 ','. ', #8]) then key: = #0; // not (key in ['0 '.. '9 ','. ', #8]) // the first digit cannot be the decimal point if (Key = '. ') and (EDT. selstart = 0) then key: = #0; // only one decimal point if (Key = '. ') and (Pos ('. ', STR)> 0) then key: = #0; // 0 cannot be inserted before (except when the first 0 is input) if (Key = '0 ') and (EDT. selstart = 0) and (STR <> '') then key: = #0; // you cannot enter 0 if (Key = '0') and (leftstr (STR, 1) = '0') and (Pos ('. ', STR) <= 0) then key: = #0; end;The above takes into account many cases, it is good to limit the input decimals. If the program has a lot of tedit to do this restriction, of course, you don't have to write code for each control, just specify the event to the same process.