2 Replies Latest reply on Aug 15, 2006 11:55 AM by Dan Bracuk

    basic

    Level 7
      Can anyone see why this wouldn't set Client.GiftCardValue to 0 if the word
      None was entered??

      Basically I'm try to eliminate one from entering text in a form field and if
      the do I just want it converted to a 0 value.

      <cfif NOT IsNumeric(TRIM(URL.amount))>
      <cfset Client.GiftCardValue = 0>
      <cfelse>
      <cfset Client.GiftCardValue = URL.amount>
      </cfif>

      TY

      Bill


        • 1. Re: basic
          Iceborer Level 1
          The code you posted worked fine for me (CF 7.0.2). Something you said intrigued me, though. You mention preventing text from being entered in form fields, yet the code you posted is using the URL scope rather than the Form scope. Is it possible that either (a) You are using the wrong scope or (b) You are doing some processing between when the form is submitted and when the URL-scoped code you posted is executing that is causing the values you retrieved from the form to be altered?

          Adam
          • 2. Re: basic
            Dan Bracuk Level 5
            quote:

            Originally posted by: Newsgroup User
            Can anyone see why this wouldn't set Client.GiftCardValue to 0 if the word
            None was entered??
            Basically I'm try to eliminate one from entering text in a form field and if
            the do I just want it converted to a 0 value.

            <cfif NOT IsNumeric(TRIM(URL.amount))>
            <cfset Client.GiftCardValue = 0>
            <cfelse>
            <cfset Client.GiftCardValue = URL.amount>
            </cfif>
            TY
            Bill


            Run this for clues

            <cfif NOT IsNumeric(TRIM(URL.amount))>
            <cfdump var="pass #TRIM(URL.amount)#">
            <cfset Client.GiftCardValue = 0>
            <cfelse>
            <cfdump var="fail #TRIM(URL.amount)#">
            <cfset Client.GiftCardValue = URL.amount>
            </cfif>