Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    .blur problem, I would like to change for a submit button

    Hi,

    I basically have this script which is working fine, but only works wen I tab off the form, I would like to change it for a submit buttin, I believe I have to change .blur to something else, can anyone help me in the right place? thanks, below are my scripts
    Code:
    <script src="jquery.js" type="text/javascript" language="javascript"></script>
    <script language="javascript">
    
    $(document).ready(function()
    {
    	
    	$("#username").blur(function()
    	{
    		//remove all the class add the messagebox classes and start fading
    		$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
    		//check the postcode exists or not from ajax
    		$.post("post_code.php",{ user_name:$(this).val() } ,function(data)
            {
    		  if(data=='no') //if postcode not avaiable
    		  {
    		  	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
    			{ 
    			  //add message and change the class of the box and start fading
    			  $(this).html('Sorry We Do Not Cover Your Area').addClass('messageboxerror').fadeTo(900,1);
    			});		
              }
    		  else
    		  {
    		  	$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
    			{ 
    			  //add message and change the class of the box and start fading
    			  $(this).html('We Cover Your Area').addClass('messageboxok').fadeTo(900,1);	
    			});
    		  }
    				
            });
     
    	});
    });
    </script>
    Code:
    <input name="username" type="text" id="username" value="" maxlength="15" onChange="javascript:this.value=this.value.toLowerCase();"/>   
       <span id="msgbox" style="display:none"></span>
    thanks
    Last edited by jay_jg; 05-04-2011 at 11:46 AM.

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Did you mean specifically a 'submit' button, or just a button? A submit button should really only be used to submit form data.

    Code:
    <button id="checkName">Check Name</button>
    jQuery:
    Code:
    $(''#checkName').click(function () {
       // check stuff
    });
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • Users who have thanked AndrewGSW for this post:

    jay_jg (05-05-2011)

  • #3
    New to the CF scene
    Join Date
    May 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi Andrew thank you for the reply

    Basically when you put in a wrong post code it will say "sorry we do not cover your area", if the user out s a correct post code in it says "we cover your area"

    I tried the .click function but even if you put a correct post code in the wrong answer pops up, I could send you the URL if you like?

    thanks

    Jamie


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •