Script evaluation for numericality

Hi
I have a text_field as
<%= text_field :sd_resol, “hours”, “size” => 2, “value” => ‘00’ %>
And on submit_to_remote :condition I am calling a script to check
whether hour contains only numeric data…How can I do it…I tried like

if(!isNumeric($F(‘sd_resol_hours’) ))

But is not working…How can I do this?Please help

Sijo

On 1 Jul 2008, at 12:10, Sijo Kg wrote:

Hi
I have a text_field as
<%= text_field :sd_resol, “hours”, “size” => 2, “value” => ‘00’ %>
And on submit_to_remote :condition I am calling a script to check
whether hour contains only numeric data…How can I do it…I tried like

if(!isNumeric($F(‘sd_resol_hours’) ))

condition needs to be a fragment of javascript which evaluates to true
(or anything javascript will consider to be true) when the request
should be made, ie :condition => “isNumeric($F(‘sd_resol_hours’))”
assuming you have a function called isNumeric that returns the
appropriate value

Fred

But is not working…How can I do this?Please help

“it’s not working” is the single most unhelpful thing you can say when
asking a question. Say what happens, what you expected to happen etc…

O sorry I thought isNumeric is a function by javascript…So things not
that much easy with javascript…I thought in the rails way that it will
do some check using regex /(^\d+$)|(^\d+.\d+$)/ …So could you please
tell me how can I do this?

Sijo

Are you trying to see if it’s an IP address?

\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}. Should suffice.

Hi
I could solve it like
var anum=/(^\d+$)|(^\d+.\d+$)/
hour=anum.test($F(‘sd_resol_hours’))
minute=anum.test($F(‘sd_resol_minutes’))
if (ho==false || min == false)
code here

  Thanks for all the reply

Sijo

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs