In my controller I have this :
validates_presence_of :order_of_importance, :on => :create, :with => /^\d{3}$/
But this would still validate ( i think ), if they typed :
4231
But I want to make sure they only type in 3 digit characters.
Any ideas?
/^\d{3}$/should do it. It makes sure that the digits start and end at the ends of the string to match.Also, you don’t need the
iat the end, since digits aren’t cased.