Your code was very concise and an appreciated analysis of the problem.
I've coded a keyCode based keydown validator that handles the 3 cases
(numeric, decimal, currency) which is what i'll probably use- It's
definitely going to be server side validated, more of a helper in the UI.
It's in the final code thread, but I will take your comments onboard all the
same.
Thanks

Gareth


On 3/9/07, RobG <[EMAIL PROTECTED]> wrote:
>
>
>
>
> On Mar 9, 11:12 am, "Mark Holton" <[EMAIL PROTECTED]> wrote:
> > ...here's a 'numbersonly' js function that I like..... this would take
> care
> > of the numbers only part... and you could easily adapt to meet your
> needs:
> > cheers,
> > Mark
> >
> > ...in the element you want to validate, simply add:
> > onkeypress="return numbersonly(event)"
> >
> > put this JS at the top of the page:
> > <script type="text/javascript">
> >     // verifies only a number was typed into the form element
> >     function numbersonly(e){
> >         var unicode=e.charCode? e.charCode : e.keyCode
>
> A strategy based on charCodes will fail at least some of the time and
> will be much longer, more verbose and less reliable than a regular
> expression.  Consider how you are going to test that only one decimal
> point is entered, or only two decimal places for currency.
>
> <URL: http://www.merlyn.demon.co.uk/js-valid.htm#VNP >
>
>
> --
> Rob
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to