如何包括空格(不是文本, 输入类型上只有空格和数字)? 当我尝试我的代码时,它仅包含数字
这是我的代码:
<form action="/action_page.php"><input type="number"/><input type="submit"</form>
答案 0 :(得分:0)
<form action="/action_page.php">
<input type="text" pattern="[0-9 ]+" />
<input type="submit"</form>
您可以将输入与文本类型一起使用,并添加模式"[0-9 ]+"
。
答案 1 :(得分:0)
您需要使用type="text"
进行输入,以便根据需要设置值的格式。 type="number"
不适用于这种格式。
const formatter = new Intl.NumberFormat('fr-FR');
<input
type="text"
value={formatter.format(value)}
/>