bacon Posted May 17, 2011 Posted May 17, 2011 I want to know how I do to make an edit only accept numbers. in WinForms I do something like this in the keydown event 'if char not in [0..9] then char := #0;' but in uniGui this seens to not work in web mode, i put a breakpoint and it goes to the event, but it seens not to change the char value and the letter is accepted. Thanks. Best Regards. Brian. Quote
Administrators Farshad Mohajeri Posted May 17, 2011 Administrators Posted May 17, 2011 I want to know how I do to make an edit only accept numbers. in WinForms I do something like this in the keydown event 'if char not in [0..9] then char := #0;' but in uniGui this seens to not work in web mode, i put a breakpoint and it goes to the event, but it seens not to change the char value and the letter is accepted. Thanks. Best Regards. Brian. Setting Char parameter has no effect in web mode. Such a control should be implemented as a new Component. It is in issue list. Quote
bacon Posted May 17, 2011 Author Posted May 17, 2011 Setting Char parameter has no effect in web mode. Such a control should be implemented as a new Component. It is in issue list. Thanks Farshad. Good work with UniGUI. Quote
thecrgrt Posted May 19, 2011 Posted May 19, 2011 Setting Char parameter has no effect in web mode. Such a control should be implemented as a new Component. It is in issue list. IMO, it's easier to add EditType for TUniEdit and TUniDBEdit, when EditType is set to "Number" then use TExtFormNumberField instead of TExtFormTextField in Web-mode, is it possible? Quote
chatop Posted May 22, 2011 Posted May 22, 2011 i Think ,best mode is if not (key in ['0'..'9','.']) then begin key:=#0; end; Quote
Administrators Farshad Mohajeri Posted May 22, 2011 Administrators Posted May 22, 2011 i Think ,best mode is if not (key in ['0'..'9','.']) then begin key:=#0; end; It does not work in web mode as keys aren't sent back to the browser. Such functionality should be implemented in client side. Quote
thecrgrt Posted May 22, 2011 Posted May 22, 2011 i Think ,best mode is if not (key in ['0'..'9','.']) then begin key:=#0; end; The only way to work around is: var AText: String; begin AText := (Sender as TUniEdit).Text; if not (key in ['0'..'9','.']) then begin (Sender as TUniEdit).Text := AText; end; end; But I'dont like this way, this should be an asynchronous method using JavaScript. Quote
chatop Posted May 22, 2011 Posted May 22, 2011 if can support javascript code on client ,will be OK Quote
rullomare Posted March 5, 2013 Posted March 5, 2013 Use ClientEvent in Tuniedit / TuniDbEdit . function OnKeypress(sender, e) { var allowed = "0123456789" ; var c = e.getCharCode() ; if (allowed.indexOf(String.fromCharCode © ) === -1 ) { e.stopEvent(); } } Quote
patmap Posted March 8, 2013 Posted March 8, 2013 Hi, This is very simple: 1) Make a Inherited class from TUniEdit (Ex: TUniNumberText = Class(TUniEdit) ) 2) Then override Loaded method; 3) Write This line into Loaded Method: ExtEdit.MaskRe := '/[0-9]/i'; Only one line ! Regards 1 Quote
rullomare Posted March 8, 2013 Posted March 8, 2013 Hi Patmap, certainly wonderful solution, but more than one line! Best Regards Quote
Sherzod Posted June 6, 2014 Posted June 6, 2014 http://forums.unigui.com/index.php?/topic/3495-how-only-number-in-tunidbnumberedit-not-double-is-it-possible/&do=findComment&comment=16284 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.