开发者

Rails validation prevent email addresses and phone numbers

开发者 https://www.devze.com 2023-04-03 03:16 出处:网络
I am looking for a way in Rails (2.3.9) to PREVENT users from entering email addresses, and phone numbers of as many formats as possible. I have a textbox, and I do not want users to be able to submit

I am looking for a way in Rails (2.3.9) to PREVENT users from entering email addresses, and phone numbers of as many formats as possible. I have a textbox, and I do not want users to be able to submit email addresses or phone numbers..

Any ideas开发者_Go百科?


Probably the most straightforward method would be to use a custom validation with validate. You can check against the regexes you want to prevent users from submitting and supply your own validation message.

I've created a gist demonstrating this behavior.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号