How To Check Or Test If a Value Is Integer | Coldfusion How Tos

Checking Or Testing If a Value / Variable Is Integer (number) In Coldfusion

check test variable value if integer number
For all of you beginner coldfusion programmer there who are wondering on how you can check or test if a value or your variable is a numeric or not.

This is of course is important because we do not want a wrong data type to use in our where clause with our cfquery right?

This is actually very easy, just use:

#isnumeric(value)#

With isnumeric function you can test if a value is an integer or not, here is a basic example.

cfset myvariable="12345"

cfif #isnumeric(myvariable)# eq true
cfset result="variable is numeric"
cfelse
cfset result="variable is not numeric"
/cfif

#result#


Of course we would put a greater than and less than sign at every start and end each line, but I know you can understand the purpose of this code.

Also, I tried doing

cfif #isnumeric(myvariable)# eq "true"

and the result is still the same.

Well, that's all for now, hope this helped you.

Happy programming and good luck to you project!

Post a Comment

 

Get the latest news and updates. Your everyday supply of the most talked topics on Philippine television and online circulations.
Keywordspeak.com articles are ALL original, please ensure proper do-follow link if reused online.

MyGlobe Rewards | Anyare.com | LET Results Secondary January 26, 2014 | LET Results Elementary January 26, 2014 | LET Teachers January 26, 2014

Copyright 2013 All Rights Reserved - Keywordspeak.com | Contact Us | Google+