?
Solved

isNaN - error when trying to validate text field

Posted on 2003-03-30
7
Medium Priority
?
250 Views
Last Modified: 2006-11-17
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
Comment
Question by:dba123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 1

Author Comment

by:dba123
ID: 8236408
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
 

Expert Comment

by:greenunicorns
ID: 8236578
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
 

Expert Comment

by:greenunicorns
ID: 8236585
oh, are you using netscape?  if so, let me know.
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 12

Accepted Solution

by:
jyokum earned 200 total points
ID: 8236645
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
 
LVL 30

Expert Comment

by:third
ID: 8237339
and 'if' instead of 'If'.
0
 
LVL 1

Author Comment

by:dba123
ID: 8243165
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
 
LVL 30

Expert Comment

by:third
ID: 8243233
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question