Thread: check if empty
View Single Post
Old March 7th, 2004, 07:38 AM
hosefo81 hosefo81 is offline
Authorized User
Join Date: Oct 2003
Location: KL, wilayah persekutuan, Malaysia.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default check if empty

when the user clicked the submit button, it will check if there is any value for the telephone textbox.If no value, then alert the user and stop submitting else submit the form.But my code below has does not work. Please help me correct it.
        #textbox {position:absolute; left:200px};
    function check(text)
            alert("Please enter telephone number");
            return false;
<body onload="; 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.value)"> <br><br>