Question : Check if string only contains ascii chars, numbers, and underscores?

Hi,

I'd like to check if a string only contains ascii characters, numbers, and underscores. Right now I can loop over a string checking that each char is one of the items mentioned, but is there a compact regular expression I can use to check this? I am guessing this will be faster than looping over the input string,

Thanks

 

Answer : Check if string only contains ascii chars, numbers, and underscores?

AFAIK, there's really no "great" solution for this.  A workable hack is to *keep* the bind's in place, but populate the initial values manually.  So the lists will show the correct default values initially, but will still be linked.

Use cfinvoke to get the initial data for each list
       
       <!--- change the parameter names if needed ...--->
      <cfinvoke component="com.remoteCalls" method="getRemoteProvince"  
                      countryId="#countryid#"
                      returnVariable="getProvinces"
          >
       ... run other methods ....

Then use the results to populate each cfselect manually. Again, *don't* remove the bind's or the lists won't be linked properly.

<cfselect name="province" bind="cfc:com.remoteCalls.getRemoteProvince({countryid})" ... etc....>
        <option value="0" selected>Select One</option>
       <cfoutput>
       <cfloop array="#getProvinces#" index="row">
      <option value="#row[1]#" <cfif row[1] eq provinceId>selected="selected"</cfif>>#row[2]#</option>
         </cfloop>
       </cfoutput>
</cfselect>

       ... populate other lists ....


BTW: Binds are great for "add new" forms, but lousy for "edit" forms IMHO.  Especially when you have a lot of related selects.  What you're trying to do is simulate the onchange event for each cfselect list.  That's easy enough.  But to get the desired results, you have trigger them in a *specific*order (ie synchronous) Otherwise, the lists won't contain the right items.  

Also, CF8 binds don't support "selected". So even if you figured out how to populate each list with the desired items, you can't easily preselect one of the items! It's a pain, but it's a known limitation of in CF8.
Random Solutions  
 
programming4us programming4us