Thread: check if empty
View Single Post
  #3 (permalink)  
Old March 7th, 2004, 09:07 AM
joefawcett's Avatar
joefawcett joefawcett is offline
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

A few changes needed.
Code:
<html>
<head>
    <title>Testing</title>
    <style>
        #textbox {position:absolute; left:200px};
    </style>
    <script>
    function check(textbox)
    {
        if(textbox.value == "")
        {
            alert("Please enter telephone number");    
            //textbox.select();
            text.focus();
            //return false;
        }
        textbox.form.submit();
    }
</script>
</head>
<body onload="document.myform.telephone.select(); document.myform.telephone.focus();">
<form name="myform" >
Telephone No. <input id="textbox" type="text" name="telephone" ><br><br>
<input type="button" value="Submit" onclick="check(document.myform.telephone)"> <br><br>
</form>
</body>
</html>
As your button is not a submit button you'll need to submit manually. I commented out the lines that didn't add anything.

--

Joe
Reply With Quote