> Why are you declaring functions inside of your $(document).ready

That was just a hangover from where I pulled that code... originally it was
part of Jorn's Validation plug-in...

Since you've created an actual function called "toggleSubmit" to toggle the
button,
how would I trigger that function, say, after this code, *if* the data
return from the
post is a string?  (In other words, the posted data was found to be
Invalid...

How would it be combined with this code:

        $("#Principal").blur(function(){ 
        $.post("callpage_Validate_Mortgage_Inputs.cfm",
{principal:$("#Principal").val()},
        function (data) {$("#Result_Principal").empty().append(data) } ) });

Pseudo-code:

        If, after the post (above), the posted data was Invalid, toggle the
button to a
        state of "disabled"...

Rick



-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Sean Catchpole
Sent: Monday, April 16, 2007 7:33 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Will this code enable & disable a submit button?


Rick,

>  onInvalid: function(form) {
Did you mean onInvalid = function(form){

Why are you declaring functions inside of your $(document).ready() ?

Below I've attached working code, give it a try:

~Sean

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head><title>Toggle Submit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="main.css" type="text/css" title='main'
media="screen" />
<style type="text/css">
* { margin:0px; padding:0px; }
img { border:0px; }
a {
  outline:none;
  display:block;
  margin:14px;
  font:14pt Calibri, Arial, sans-serif;
  color:#000;
}
body { text-align:center; margin:30px; }
</style>
<script type="text/javascript"
src="http://jquery.com/src/jquery-latest.pack.js";></script>
<script type="text/javascript">

  var enabled = true;
  toggleSubmit = function(form){
    if(enabled)
      $("input:submit",form).attr("disabled","disabled");
    else
      $("input:submit",form).attr("disabled","");
    enabled = !enabled;
  }

</script>
</head><body>
<form>
<a href="javascript:toggleSubmit($('form'));">Toggle Submit</a>
<input type="submit" value="Submit">
</form>
</body></html>


Reply via email to