• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

isNaN - error when trying to validate text field

I get an "Object Expected" when I try to use my if statement in a function that is called
I just want to validate a text field

     If(isNaN(document.Mainform.NoPicsToRestore.value))
           {
          Alert("You have not entered a Valid number for Pictures to Restore");
          Mainform.NoPicsToRestore.focus();
          return false;
            }
0
dba123
Asked:
dba123
  • 2
  • 2
  • 2
  • +1
1 Solution
 
dba123Author Commented:
I have also tried:

    If(isNaN(document.Mainform.NoPicsToRestore.value) == true)
          {
         Alert("You have not entered a Valid number for Pictures to Restore");
         Mainform.NoPicsToRestore.focus();
         return false;
           }
0
 
greenunicornsCommented:
I'm pretty sure you are supposed to take out the "document." and just say "Mainform.NoPicsToRestore.value" and so on.

Also, when you created the element called mainform, did you set its "name" attribute to be Mainform or did you set its "id" attribute to be that?  Supposedly you are never supposed to use the "name" attribute.

So you should not say <form name="Mainform">, you should say <form id="Mainform"> to be safe.
0
 
greenunicornsCommented:
oh, are you using netscape?  if so, let me know.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jyokumCommented:
remember, CaSE maTTeRs

Alert should be alert

greenunicorns, "document." isn't necessary, it just further qualifies the DOM model. it doesn't hurt to leave it in. also, i've never use id to reference a form, i always use name.
0
 
thirdCommented:
and 'if' instead of 'If'.
0
 
dba123Author Commented:
yes, it was my case.  First I had Alert instead of alert, second like the other guy said, I had If instead of if.  I give you the points since you talked about the case problem first.   Man, I had this, going from ASP to Javascript...what a pain to remember stuff straight on syntax
0
 
thirdCommented:
just remember most of the functions in javascript are in lowercase but there are also functions which uses combination of the two like 'indexOf()'. when you get used to it, it will be just easy.

regards,

third ;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now