Daemach. errr. John. :o)

Here's the code I've written from yours
with the validation I need.  I can't seem
to figure out a way to make taconite happy
with this.

Got any clues?

Rick

Here's the revamped code based on what you sent me:
        
----------------------------------------------------------------------------
-----   

<CFSET Principal_Error_Message = "">
<CFSET Interest_Error_Message = "">
<CFSET Years_Error_Message = "">
        
        
<CFIF IsDefined("Form.Principal">

        <CFIF Not Len(Trim(Form.Principal))>
        
                <CFSET Principal_Error_Message = "Please enter the Principal
amount.">
                
        <CFELSEIF Len(Trim(Form.Principal))
              and Not IsNumeric(REReplace(Form.Principal, "[$.,]", "",
"All"))>
                  
                <CFSET Principal_Error_Message = "Please enter a valid
Principal amount.">
                
        </CFIF>
        
</CFIF>


<CFIF IsDefined("Form.Interest")>

        <CFIF Not Len(Trim(Form.Interest))>
        
                <CFSET Interest_Error_Message = "Please enter the Interest
Rate.">
                
        <CFELSEIF Len(Trim(Form.Interest))
              and Not IsNumeric(REReplace(Form.Interest, "[.]", "", "All"))>
                  
                <CFSET Interest_Error_Message = "Please enter a valid
Interest Rate.">
                
        </CFIF>
        
</CFIF>


<CFIF IsDefined("Form.Years")>

        <CFIF Not Len(Trim(Form.Years))>
        
                <CFSET Years_Error_Message = "Please enter the Years.">
                
        <CFELSEIF Len(Trim(Form.Years))
              and Not IsNumeric(REReplace(Form.Years, "[0-9]", "", "All"))>
                  
                <CFSET Years_Error_Message = "Please enter a valid number of
Years.">
                
    </CFIF>
        
</CFIF>

----------------------------------------------------------------------------
-----

<CFIF Not Len(Trim(Principal_Error_Message))
   and Not Len(Trim(Interest_Error_Message))
   and Not Len(Trim(Years_Error_Message))>
        
     <cfset interest = form.interest/(12*100)>   
     <cfset payment =
form.principal*(interest/(1-(1+interest)^-(form.years*12)))> 
        
        
    <cfcontent type="text/xml" reset="yes">
    <cfheader name="Content-Type" value="text/xml"> 
    <cfoutput>
    <taconite>
        <replaceContent select="##Result_Principal">
                        <cfif
listFindNoCase(lacking,"Principal")><CFOUTPUT>#Principal_Error_Message#</CFO
UTPUT></cfif>
        </replaceContent>
        <replaceContent select="##Result_Interest">
            <cfif
listFindNoCase(lacking,"Interest")><CFOUTPUT>#Interest_Error_Message#</CFOUT
PUT></cfif> 
        </replaceContent>
        <replaceContent select="##Result_Years">
            <cfif
listFindNoCase(lacking,"Years")><CFOUTPUT>#Years_Error_Message#</CFOUTPUT></
cfif>
        </replaceContent> 
        <replaceContent select="##Result">
            <cfif listLen(lacking)>Waiting for numbers...<cfelse>Your
payment is: #DollarFormat(payment)#!</cfif>
        </replaceContent> 
    </taconite>
    </cfoutput>
    
    <!---If there are form fields submitted, this must be an ajax call.
Otherwise show the form--->
    <cfelse>
    <html xmlns=" http://www.w3.org/1999/xhtml";>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
    <title>Mortgage Calculator</title> 
    <script type="text/javascript" src="2007_0307_jquery.js"></script>
    <script type="text/javascript" src="jquery.taconite.js"></script>
    <script language="JavaScript" type="text/javascript"> 
        $.taconite.debug = true; 
        
        $(document).ready(function(){
            $("input:text").each(function(){
              $(this).blur(function () {
                        var Params = {}; 
                        $("input:text").each(function(){
                            Params[$(this).attr("name")] = $(this).val();
                        });
                        $.post(" CalcTest.cfm",Params);
                    });
              });
        }); 
    </script>
    </head>
    <body>
    <h3>Mortgage Calculator</h3>
    <form id="Calculate_Mortgage" Name="Calculate_Mortgage"> 
        <table>
                
            <tr>
                                <td id="Result_Principal"></td>
                        </tr>
                        
                        <tr>
                <th align="left">Principal:</th>
                <td><input tabindex="1" id="Principal" name="Principal"
type="Text"></td> 
            </tr>
                        
            <tr>
                                <td><div id="Result_Interest"></div></td>
                        </tr>
                        
                        <tr>
                <th align="left">Interest:</th> 
                <td><input tabindex="2" id="Interest" name="Interest"
type="Text"></td>
                        </tr>

            <tr>
                                <td><div id="Result_Years"></div></td>
                        </tr>
                        
                        <tr>
                <th align="left">Years:</th>
                <td><input tabindex="3" id="Years" name="Years"
type="Text"></td> 
            </tr>
                        
            <tr>
                <th align="left">Result: </th>
                <td><div id="Result"></div></td>
                <td>&nbsp;</td>
            </tr>
        </table>
    </form>
    </body> 
    </html>
</cfif>



_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to