Basic Javascript question

I am attempting validate a field. Just one text field. I want to make sure that it has a value in it. Below is my code, but it’s not working any ideas. Thanks inadvance

function validateFields(){

var frm = document.forms[0];

if (frm.DX.value == “Other” & frm.Other.value ==“”){

alert(“Please enter something”);

frm.other.focus();

return false;

}

}

Subject: Basic Javascript question

The code looks the same as the code I use to validate fields however where have you put this code - I usually use the onSubmit option

Subject: Basic Javascript question

I notice you have 2 references to a field called other - they have different cases, the first has a capital ‘O’. Might be worth checking.

Subject: Basic Javascript question

The problem might be the type object that DX is. What kind of field is DX on the form? If your field is a dialog list or radio button or checkbox, you’ll need more code to check for a text value of “Other”. View the source for the document to make sure DX isn’t a JavaScript Select, Checkbox, or Radio object. The “…forms[0].fieldname.value” reference only works for plain fields. These other types are arrays that you’ll either have to loop through or use specific properties such as “selectedIndex” to determine what’s been selected.

If DX is a radio button field, then you would test for an “Other” selection like so:

function validateFields(){

var checkedButton = ""



for (var i in frm.DX) {

    if (frm.DX[i].checked==true ) {

        checkedButton=frm.DX[i].value

    }

}



if (checkedButton == "Other" & frm.Other.value ==""){

    alert("Please enter something")

    frm.Other.focus()

    return false

}

}

You don’t need semicolons at the end of statements in JavaScript. Semicolons are used to separate complete statements on a single line as in a=1+2 ; b = 2+3.

Subject: RE: Basic Javascript question

Whoa! Hey Willy! How you been, man? Email me if you get the chance: nathan@e-md.co.za

Subject: Basic Javascript question

I create a function and call it onsubmit