0

I have a Fluid Problem.

This code:

<f:form.textfield class="wettersuchinput" maxlength="4" type="email" name="zip" value="{zip}" placeholder="PLZ für Lokalwetter eingeben"/>

I want to fill just numbers in this input textfield. I tried to change the type in numbers, but that's not that i want to.

Can anybody help me to allow just numbers in this textfield ?

I am looking for a soluthion without viewhelper.

Thank you

4

1 回答 1

0

使用pattern输入字段上的属性:

<f:form.textfield maxlength="4" name="zip" value="{zip}" additionalAttributes="{pattern: '[0-9]{4}'}"/>

只允许输入正好由四位数字组成。输入是否有效可以由 CSS 伪类:valid:invalid.

当然,这不适用于所有浏览器(是的,我在看你,IE),而且它不能帮助你提高安全性——恶意用户可以很容易地绕过这一点。使用服务器端验证来确保安全。

于 2013-04-17T14:07:02.160 回答