Simple JS question

i have an app that needs to check if comments are there is a user selects Yes from a radio button interface. choices are Yes/No

THere is no alert even though i check Yes and leave comments blank

here is what i have now:

function (chkPage){

txt=document.forms[0];

if(document.forms[0].SoftwareChanges[0].checked && txt.SoftwareComments==“”){

alert(“You must provide comments since you selected YES to a change in this area”);

document.forms[0].SoftwareComments.focus();

return false;

}

more code… then

return true;

}

if(chkPage()==true){

function goSubmit()

{

document.forms[0].submit();

return false;

}

}

Subject: Simple JS question

You have txt set to document.forms[0]. txt.SoftwareComments is a field (probably a textarea), so it can never equal a string, even an empty one. You also have “function (chkPage)”, which is a syntax error.

I’d start with using a different variable name for the form – “txt” is confusing, since it seems to indicate a text value. try this:

function chkPage() {

var f = document.forms[0];

if (f.SoftwareChanges[0].checked && f.SoftwareComments.value == ‘’) {

alert(“You must provide comments since you selected YES to a change in this area”);

document.forms[0].SoftwareComments.focus(); return false;

.

.

.

Subject: RE: Simple JS question

thanks for your help

Subject: Missing .value

txt=document.forms[0];if(txt.SoftwareChanges[0].checked && txt.SoftwareComments.value == “”){

alert(“You must provide comments since you selected YES to a change in this area”);

txt.SoftwareComments.focus();

return false;

}