PDA

View Full Version : checking for the text field empty


phani
09-04-2002, 06:43 AM
can u guide in solving my problem. i have to raise an alert on clicking a button if the text field is empty.can u tell what's wrong in the code here:

if(isEmpty(doucment.forms[0].txt_topicname.value))
{
alert("FIELD CAN'T BE EMPTY");
document.forms[0].txt_topicname.focus();
}

mat
09-04-2002, 12:13 PM
hi,

Your first spelling of "doucment" is wrong (should be like the other = document) so fix that and see if it helps, also you could try this as another method:

<script language=ja....


function checkTopic(){
topicName=document.form.txt_topicname.value
if (topicName == ""){
alert("FIELD CAN'T BE EMPTY!");
form.txt_topicname.focus();
}
}

</script>


<body>

..

<input type="text" name="txt_topicname" onBlur="checkTopic()">



:)

mat