Karthik Kantharaj wrote:
> hi guys
> 
> Thanks for the support you give
> 
> I have some four fields which is not mandatory, but when that field is
> entered need to be validated before saved
> else 
> it can take null value
> can you please guide me
> --
> Karthik.k
> Mobile - +91-9894991640

Assume that you have an age field that should not be validated if it is 
blank.  But should be validated when something is entered

#your Model

class Employee < ActiveRecord::Base
  validates_numericality_of :age, :allow_blank=>true
end

This will let blank but when something is there it will be validated for 
numbers.

http://www.classifiedscript.in
Craigslist Clone
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to