最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Restricting text field to numbers only in Gravity Forms

programmeradmin4浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 9 years ago.

Improve this question

We're trying to restrict a text field to numbers only. Here's what we've tried

  • Add text field
  • Apply input mask (9999999999)

The problem is that if someone does not fully complete the field, the number is erased when they tab into the next field or if they click anywhere outside of that field. It should not matter how many characters they put into the field, it should just restrict the field to a number.

If one only puts one 9 in the field, it restricts the field to 1 number. With the input mask set to ten 9's, you can enter 10 numbers. The problem is that if you do not enter the exact number, it clear the field once it loses focus.

We can do this with jQuery but we're hoping that Gravity has a hidden gem we've missed somewhere?

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 9 years ago.

Improve this question

We're trying to restrict a text field to numbers only. Here's what we've tried

  • Add text field
  • Apply input mask (9999999999)

The problem is that if someone does not fully complete the field, the number is erased when they tab into the next field or if they click anywhere outside of that field. It should not matter how many characters they put into the field, it should just restrict the field to a number.

If one only puts one 9 in the field, it restricts the field to 1 number. With the input mask set to ten 9's, you can enter 10 numbers. The problem is that if you do not enter the exact number, it clear the field once it loses focus.

We can do this with jQuery but we're hoping that Gravity has a hidden gem we've missed somewhere?

Share Improve this question edited Dec 21, 2015 at 19:15 SixfootJames asked Dec 21, 2015 at 13:33 SixfootJamesSixfootJames 4573 gold badges11 silver badges23 bronze badges 3
  • As per the screenshot which you have provided, you want user to enter 10 digits. Ideally, clearing the value should be OK if user does not enter complete 10 digits. Please clarify if you want to allow user to input less than 10 digits? – Prasad Nevase Commented Dec 21, 2015 at 14:53
  • @ItsMePN, I have made some edits to clarify. – SixfootJames Commented Dec 21, 2015 at 19:15
  • Thanks, I was going to provide same answer which David provided below. I think you shall be good now. – Prasad Nevase Commented Dec 22, 2015 at 4:15
Add a comment  | 

1 Answer 1

Reset to default 4

If you add a question mark before your string of 9s, this will work as desired. It makes the completion optional. It will still enforce a max limit based on the number of 9s you have but there will be no minimum limit.

发布评论

评论列表(0)

  1. 暂无评论