<cfset isValid = (n * 10) mod 5 eq 0>

That works unless you try something like 2.05
<cfset isValid = (2.05 * 10) mod 5 eq 0>
<cfoutput>isValid : #isValid#</cfoutput>
isValid : YES
but should fail



On Sat, Feb 20, 2010 at 1:28 AM, Kevan Stannard <[email protected]> wrote:
>
> This might do:
>
> <cfset isValid = (n * 10) mod 5 eq 0>
>
>
> On 20 February 2010 17:41, Marie Taylore <[email protected]> wrote:
>
>>
>> I have an app that I need to validate that they enter either whole numbers
>> (1,2,3, etc.) or if they DO enter a decimal, it can only be in half
>> increments, so 2.5 is okay, but not 2.1, 2.2, 2.25, etc.  Of course, 2.0
>> would be okay too, so .0 after the number is fine.
>>
>> Is there a good way to check that with Regex rather than parsing the string
>> and checking that the value after the period is a 5 or a 0?
>>
>> Thanks,
>>
>> MarieT
>>
>>
>>
>>
>>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:330980
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to