View Full Version : validation help

06-21-2004, 04:08 PM
I am using this script to validate a field called "field"


<!-- Begin
function verify() {
if (document.fileupload.first.value=="") {
alert("Please attach a file to upload");
return false;
// End -->

However, when I use a name like this for the field "wcsave_a9-photofile" as

it will not validate. Is there any reason for this?

thanks in advance

06-21-2004, 04:24 PM
the JS could think that the "-" in the name is a minus and might be trying to do a calculation?

that's all I can think of at the mo!

06-21-2004, 04:43 PM
I replaced the "-" with a "_" and it seems to work fine. Thanks for the help :)

06-21-2004, 04:48 PM
happy to help :D glad you got it sorted! :thumbsup:

06-22-2004, 04:47 AM
Another way of accessing field is the "elements" collection using the bracket notation (http://www.litotes.demon.co.uk/js_info/sq_brackets.html). This is specially helpful if the name of the field has special characters that are illegal when accessed using the dot notation, as in this case.

if (document.fileupload.elements["wcsave_a9-photofile"].value=="") ...