Hi, all...
I've been tinkering with jQuery for about 3 weeks now and while
I've made some progress and gotten some things to work, I'm
stuck on validation and I've got to get it working so I can do something
that makes money!
Anyway... here's what I've got. If anyone could give me the advice I need
to get this working I'd be very grateful...
I'm trying to run validation on each form field of a form on blur. Right
now
I'm just working on one form field.
I've got my page with the validation code (trying to use $post) and my form.
I've also set up my processing page (.cfm). However, nothing seems to be
happening with the processing. The form just acts like a regular form.
Firebug isn't complaining of any js errors...
Here are the 3 parts involved:
jQuery:
<script type="text/javascript">
function ValidatePrincipal(){
var Params = {};
$("input:text").each(function(){
Params[$(this).attr("name")] = $(this).val();
});
// "post" the form. The Params object mimics form fields
$.post("callpage_Validate_Mortgage_Inputs.cfm", Params,
['Principal'], function(data){
// this is the processing function.
// append what you get back to the element with ID = Result
after clearing its contents
$("#Result").empty().append(data);
} // closes post function
); // closes ( after .post
} // closes { after ValidatePrincipal()
</script>
Form HTML:
<body>
<Form id="ValidatePrincipal" Name="ValidatePrincipal">
<table>
<tr>
<td>
Result: <Span id="Result"></span>
</td>
</tr>
<tr>
<td>
Principal: <INPUT ID="Principal" Name="Principal"
Type="Text" Value="" Size="20" Class="TextInput01"
onBlur="ValidatePrincipal">
</td>
</tr>
<tr>
<td>
Interest: <INPUT ID="Interest" Name="Interest"
Type="Text" Value="" Size="20" Class="TextInput01">
</td>
</tr>
</table>
</Form>
</body>
And finally, the .cfm processing code:
<CFIF Value="Principal">
<CFSET Principal_Error_Message = "">
<CFIF Len(Trim(Form.Principal)) and Not
IsNumeric(REReplace(Form.Principal, "[.$,]","","All"))>
<CFSET Principal_Error_Message = "Please enter a valid
dollar amount.">
<CFELSEIF Not Len(Trim(Form.Principal))>
<CFSET Principal_Error_Message = "Please enter a value for
the Principal.">
</CFIF>
<CFCONTENT
Reset="Yes"><CFOUTPUT>#Principal_Error_Message#</CFOUTPUT>
</CFIF>
</CFIF>
Any hints why this is not working?
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/