Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 706581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:10:56+00:00 2026-05-14T04:10:56+00:00

I am trying to validate the format of non-negative integers with the following validates_format_of

  • 0

I am trying to validate the format of non-negative integers with the following

validates_format_of :fundays, :with => /\A[\d]+\Z/, :message => "invalid fundays"

And here is the form field used in the view

<%= f.text_field :fundays, :maxlength => 3, :style => 'width:50px;' %>

However, when I input a non-digit into this field and submit the form, it does not fail the validation. Instead it saves a value of 0 in the database. How do I make it write to the list of error messages.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:10:57+00:00Added an answer on May 14, 2026 at 4:10 am
    validates_numericality_of :fundays, :only_integer =>true, 
                              :greater_than_or_equal_to =>0, 
                              :message => "invalid fundays"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to validate mm-dd-(2012~2099) date format. I have the following regular expression. ^(0[1-9]|1[0-2])-(0[1-9]|[10-31])-(20[12-99])$
While trying to validate form data on my page i get the following error:
I am trying to validate following date format through regExp , but still i
I have a form where i'm trying to validate that a field called birthday
I have the following form. I am trying to validate the inputs using jquery
I'm trying to use a .NET Regex to validate the input format of a
When trying to validate my site, I get the following error: Line 188, column
While trying to validate my forms i get the following error: Expected a {
I am trying to validate a date in the format dd/mm/yyyy using a function
I have a jQuery Dialog form and on submit I'm trying to validate the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.