Jump to content

can't tell why it won't work


harkly

Recommended Posts

Can someone help figure out why I can't get this AJAX code to work with only my CSS form and not with the tables version ? I could use just tables but am very curious as to why it won't work.

 

I am checking to see if the email entered is valid.

 

The AJAX ::

 


<SCRIPT type="text/javascript">
<!--
/*
Credits: Bit Repository
Source: http://www.bitrepository.com/web-programming/ajax/userID-checker.html 
*/

pic1 = new Image(16, 16); 
pic1.src = "loader.gif";

$(document).ready(function(){

$("#email").change(function() { 

var usr = $("#email").val();

if(usr.length >= 4)
{
$("#status2").html('<img src="loader.gif" align="absmiddle"> Checking availability...');

    $.ajax({  
    type: "POST",  
    url: "checkPswd.php",  
    data: "email="+ usr,  
    success: function(msg){  
   
   $("#status2").ajaxComplete(function(event, request, settings){ 

if(msg == 'OK')
{ 
        $("#email").removeClass('object_error'); // if necessary
	$("#email").addClass("object_ok");
	$(this).html(' <img src="tick.gif" align="absmiddle">');
}  
else  
{  
	$("#email").removeClass('object_ok'); // if necessary
	$("#email").addClass("object_error");
	$(this).html(msg);
}  
  });
} 
  }); 
}
else
{
$("#status2").html('<font color="red">The email should have at least <strong>4</strong> characters.</font>');
$("#email").removeClass('object_ok'); // if necessary
$("#email").addClass("object_error");
}

});

});

//-->
</SCRIPT>

 

Works with the following --

 

<form  method='post' action='resetUpdate.php' name='mailcheck' id='form_id' ">

    <tr>
      <td width="200"><div align="right">email: </div></td>
      <td width="100"><input id="email" size="20" type="text" name="email"></td>
      <td width="300" align="left"><div id="status2"></div></td>
    </tr>  

    <label for='userID'>Username </label><input type="radio" name="forgot" value='userID' class='outline'>
    <br><label for='pswd'>Password </label><input type="radio" name="forgot" value='pswd' class='outline'>

</form>

 

 

but not with this --

 

<form  method='post' action='resetUpdate.php' name='mailcheck' id='form_id'>

  <fieldset><legend>Change Password </legend>
    <span class='textbox'>
      <label for='email'>Enter your email: </label><input id="email" size="35" type="text" name="email" class='zip'><div id="status2"></div>

      <label for='userID'>Username </label><input type="radio" name="forgot" value='userID' class='outline'>
      <br><label for='pswd'>Password </label><input type="radio" name="forgot" value='pswd' class='outline'>
    </span>
  </fieldset>


</form>

 

Not sure how this line works but I do not have it in my stylesheet

 

<div id="status2"></div>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.