[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to read an integer from the minibuffer

From: Jean Louis
Subject: Re: How to read an integer from the minibuffer
Date: Sat, 13 Nov 2021 10:33:43 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

* Yuri Khan <> [2021-11-12 10:23]:
> A form control for integer numbers only permits typing digits (as you
> initially asked). Now the user cannot enter -42.

Integers may be negative.

> My bank’s money transfer web form’s amount field filters keypresses to
> only allow digits. One, I cannot paste a number I copied from an
> invoice opened elsewhere. Two, I cannot press Ctrl+L to activate my
> browser’s address bar, or switch to another tab with Ctrl+PgUp,
> Ctrl+PgDn, or Alt+[1…9]. Three, I can’t move my cursor if I
> inadvertently skip or mistype a digit, e.g., to correct a 1000 to
> 15000, I cannot type ‘← ← ← 5’, I have to type ‘backspace backspace
> backspace 5 0 0 0’.

Totally right, the field shall be given to user to freely type and
handle until user presses ENTER. On the other hand certain control is

> A bank money transfer is confirmed with a 4-digit code that is sent in
> an SMS message. As soon as you type the 4th digit, it goes on to
> verify the code, without you having to press Enter. However, this
> means you cannot immediately correct a mistyped 4th digit; you get a
> “verification failed” message first.

That is right, those are good example from life.

> Guideline: Perform input validation only after the user has
> indicated they are finished with data entry.

Those examples are not much relevant to Emacs Lisp, it's interface is
quite different to browsers. And it does not have Javascript.

The function `read-number' allows user to enter anything and press
ENTER, upon that program verifies if it is the number or not, and
advises user to enter the number.

That I see as good way to go.

What is not logical to me is to remove the previously entered
information. If user enters "123n", I get message to enter number, but
then it would be useful to provide "123n" again in the same line as to
easier correct it.


Take action in Free Software Foundation campaigns:

In support of Richard M. Stallman

reply via email to

[Prev in Thread] Current Thread [Next in Thread]