title: how to disable button and Jquery code for that button - asp.net mvc-3
body: <p>there seems to be another problem ..not with JQuery code but with Action controller code...</p>
  
  <p>i am putting the breakspoints on controllers and start debugging the app, its straight away going to controller and trying to pass in the null values ...please have a look and let me know... thx </p>
  
  <pre><code>public class HomeController : Controller
      {
          //
          // GET: /Home/
          UsersRepository repo = new UsersRepository();
          DBHelpers db = new DBHelpers();
  
          public ActionResult Index()
          {
             var users = new Users();
             return View(users);
          }
  
          public ContentResult CheckLogin(Users checkuser)
          {
              checkuser = new Users();
              if (db.CheckUserLoginDetails(checkuser))
              {
                  return Content("Login Successful:" + checkuser.Email);
              }
              else
              {
                  return Content("Login UnSuccessful");
              }
          }
  
  
          public ContentResult Register(Users userRegister)
          {
              userRegister = new Users();
              if (db.InsertNewUSerDetails(userRegister))
              {
                  return Content("Registration Successful : your ID is : " + userRegister.UserID);
              }
              else
              {
                  return Content("There was a problem addding you, please try again");
              }
          }
      }
  </code></pre>
  
  <p>=================</p>
  
  <h1>here is my DBHelpers class</h1>
  
  <pre><code>UsersRepository db = new UsersRepository();
  
          public bool CheckUserLoginDetails(Users user)
          {
              return (from u in db.EUsers where u.Email == user.Email &amp; u.Password == user.Password select u).Any();
          }
  
          public bool InsertNewUSerDetails(Users newUser)
          {
              newUser = new Users();
              try
              {
                  var date = DateTime.Now.Date;
                  newUser.JoiningDate = date;
                  db.EUsers.Add(newUser);
                  db.SaveChanges();
                  return true;
              }
              catch (DbEntityValidationException dbEX)
              {
                  foreach (var validationerrors in dbEX.EntityValidationErrors)
                  {
                      foreach (var valerror in validationerrors.ValidationErrors)
                      {
                          Trace.TraceInformation("Property: {0} Error: {1}", valerror.PropertyName, valerror.ErrorMessage);
                      }
                  }
                  return false;
              }
  
          }
  </code></pre>
  
  <h1>        }</h1>
  
  <h1>and here is my Users class</h1>
  
  <pre><code>public class Users
      {
          [Key]
          public virtual int UserID { get; set; }
  
          [Required(ErrorMessage="Required")]
          public virtual string FirstName { get; set; }
  
          [Required(ErrorMessage = "Required")]
          public virtual string LastName { get; set; }
  
          [Required(ErrorMessage = "Required")]
          [DataType(DataType.EmailAddress)]
          public virtual string Email { get; set; }
  
          [Required(ErrorMessage = "Required")]
          [DataType(DataType.Password)]
          public virtual string Password { get; set; }
  
          [DataType(DataType.Date)]
          public virtual DateTime JoiningDate { get; set; }
  
      }
  </code></pre>
  
  <p>==============
  problem is when i try to run the application, its directly going to Register() action and passing the null values ...</p>
  
  <p>please help... </p>
  
  <p>=================</p>
  
  <h1>here is my View Code...</h1>
  
  <pre><code>@model Temp1.Models.Users
  
  @{
      ViewBag.Title = "Index";
  }
  
  &lt;script src="@Url.Content("~/Scripts/jquery-1.5.1.js") type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery-1.5.1-vsdoc.js") type="text/javascript"&gt;&lt;/script&gt;
  
  @using (Html.BeginForm())
  { 
      &lt;fieldset&gt;
      &lt;div id="divLoginInfo"&gt;
      &lt;p&gt;if not registered, please @Html.ActionLink("Register", "Register", "Home", new { @id = "lnkRegister" })&lt;/p&gt;
  
      @Html.TextBoxFor(model =&gt; model.Email, new { @class = "text" })
      &lt;br /&gt;
      @Html.PasswordFor(model =&gt; model.Password, new { @class = "text" })
  
      &lt;p&gt;
          &lt;input type="button" value="Login" id="btnLogin" /&gt;
      &lt;/p&gt;
  
      &lt;div id="Result"&gt;
          &lt;div class="Loading" style="display:none;"&gt; Checking....&lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt;
      &lt;/fieldset&gt;
      &lt;br /&gt;
  
      &lt;div id="divRegisterInfo" style="display:none;"&gt;
          &lt;fieldset&gt;
          &lt;legend&gt;Users&lt;/legend&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.FirstName)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.FirstName)
              @Html.ValidationMessageFor(model =&gt; model.FirstName)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.LastName)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.LastName)
              @Html.ValidationMessageFor(model =&gt; model.LastName)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.Email)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.Email)
              @Html.ValidationMessageFor(model =&gt; model.Email)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.Password)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.Password)
              @Html.ValidationMessageFor(model =&gt; model.Password)
          &lt;/div&gt;
         &lt;p&gt;
              &lt;input type="button" value="Create"  id="btnRegister" /&gt;
          &lt;/p&gt;
  
          &lt;p&gt;
              &lt;div id="divShowRegistrationMessage"&gt;
  
               &lt;/div&gt;
          &lt;/p&gt;
  
      &lt;/fieldset&gt;
  
      &lt;/div&gt;
  }
  
  
  
  &lt;script type="text/javascript"&gt;
      $('#btnLogin').click(function (e) {
          var email = $('#Email').val();
          var Password = $('#Password').val();
          var postdata =
          {
              "Email": email,
              "Password": Password
          };
          $('.Loading').fadeIn(50);
          $.ajax({
  
              url: '@Url.Action("CheckLogin","Home")',
              data: postdata,
              success: function (msg) {
                  var data = msg.split(':');
                  $('#Result').html(data[0]);
                  $('.Loading').fadeOut(50);
               },
              error: function (data) {
  
                  $('#Result').html(data);
                  $('.Loading').fadeOut(50);
              }
  
          });
          e.preventDefault();
      });
  
      $('#lnkRegister').click(function (e) {
          e.preventDefault();
          $('#divLoginInfo').fadeOut(100);
          $('#divRegisterInfo').fadeIn(100);
      });
  
      $('#btnRegister').click(function (e) {
  
          var firstName = $('#divRegisterInfo #FirstName').val();
          var lastName = $('#divRegisterInfo #LastName').val();
          var email = $('#divRegisterInfo #Email').val();
          var password = $('#divRegisterInfo #Password').val();
          var postdata =
              {
                  "FirstName": firstName,
                  "LastName": lastName,
                  "Email": email,
                  "Password": password
              };
  
          $("#divShowRegistrationMessage").html('Pleaes wait...');
          e.preventDefault();
          $.ajax({
              type: 'POST'    
              url: '@Html.Action("Register","Home")',
              data: postdata,
              success: function (msg) {
                  $('#divShowRegistrationMessage').html(msg);
              },
              error: function (data) {
                  $('#divShowRegistrationMessage').html(data);
              }
          });
  
      });
  &lt;/script&gt;
  </code></pre>