Results 1 to 3 of 3

Thread: Checking a textfield [Resolved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    71

    Resolved Checking a textfield [Resolved]

    Hi guys,

    I was wondering how you check if a textfield is empty or not before you submit. Maybe a pop up will appear and tell the user that he/she needs to enter a value if there is no value in it.

    Irwin
    Last edited by lchi; Jan 25th, 2005 at 03:39 AM.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Checking a textfield

    Use client side Javascript to check if the textbox is empty or not.

    There are (literally) thousands of examples:
    http://www.google.com/search?hl=en&l...on&btnG=Search

  3. #3
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: Checking a textfield [Resolved]

    Quote Originally Posted by lchi
    Hi guys,

    I was wondering how you check if a textfield is empty or not before you submit. Maybe a pop up will appear and tell the user that he/she needs to enter a value if there is no value in it.

    Irwin
    Here is a quick exmaple

    HTML Code:
    <html>
    	<head>
    		<script>
    			function validate()
    			{
    				if (document.form1.txtName.value=="")
    				{
    					alert("Please enter your name");
    					document.form1.txtName.focus();
    					return false;
    				}
    
    
    				if (document.form1.txtEmail.value=="")
    				{
    					alert("Please enter your email");
    					document.form1.txtEmail.focus();
    					return false;
    				}
    
    			}
    		</script>
    	</head>
    	
    	<body>
    		<form name=form1 onsubmit="return validate()">
    			Name : <input type=text name=txtName><br>
    			Email: <input type=text name=txtEmail>
    			<input type=submit>
    		</form>
    	</body>
    </html>
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

Posting Permissions

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



Click Here to Expand Forum to Full Width