SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    224
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question If text not written , hide submit button

    How to do this ?

    i need only for one <input type="text" size="16" name="name">

    thanks for help

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this maybe:

    (put in <head> section)

    Edit:


    SEE BELOW!!


    And this HTML:

    Code HTML4Strict:
    <input type="text" size="16" name="name" id="InputBox">
    <input type="submit" value="Submit" id="SubmitButton">
    Last edited by JimmyP; Apr 12, 2008 at 06:53.
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    224
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes , but if clean the text after write,the submit button not hidden...

  4. #4
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Eh ok...

    The above script is rubbish!

    Try this one:

    Code JavaScript:
    window.onload = function() {
    	var input = document.getElementById("InputBox");
    	var button = document.getElementById("SubmitButton");
    	if(button.style.visibility = "hidden") var visible = false;
    	input.onkeyup = function() {
    		if(input.value != "" && !visible) {
    			button.style.visibility = "visible";
    			visible = true;
    		} 
    		if(input.value=="") {
    			button.style.visibility = "hidden";
    			visible = false;
    		}
     
    	}
     
    }
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  5. #5
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    224
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Very good,thanks

  6. #6
    SitePoint Enthusiast dotcompals's Avatar
    Join Date
    Jul 2007
    Location
    India
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Smolf3d View Post
    Very good,thanks
    can I see a demo of the above script.. please.

  7. #7
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    224
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)


Bookmarks

Posting Permissions

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