[Javascript] required entry field

BEKIM BACAJ trojani2000 at hotmail.com
Fri Mar 28 17:50:32 CST 2003


Correction to my previous reply that is being held by Latech server.
  If <input...> is placed inside the <form...> object, this script (my 
script) will not function at all:

function isValid() {    if(NeverBlank.value==''){
         NeverBlank.focus()
                 }
        }
It will generate error: "Object Expected".


Rodneys script :
function isValid(form) {
	if(form.NeverBlank.value==''){
    form.NeverBlank.focus()
	}
   }
will not work in ether casse, it will genareate Error: '"NeverBlank" is null 
or not an Object', in both cases.

All items inside the form object become slaves or somekind of captives by 
form individual, their names or IDs will not be processed, and will have no 
rights to speak in their names, only the form master will act as 
representative and is allowed to communicate with them.
Because of that, you will have to ask the Form waht is the name or the value 
of the item(x).

So in this casse, (forms introduce some security issues) my script will have 
to get modified into this:
(Presumming that the formname is 'myForm')
function isValid() {
if(myForm.NeverBlank.value=='')
   {
myForm.item(0).focus()//if first input in the collection
    document.forms(0).item(0).focus()//if first form in the document (uggly 
and very unoptimized)
   }
}
So these are the ways one can access inputs (items) inside the form:

a. doument.forms(n).item(n) //'n' stands for numeric value
b. myForm.item(n)
c. myForm.NeverBlank

But the best is the last.(it executes faster) 3x, if only one form in the 
document and only one item in the form, and as the number increases the 
difference of speed follows by multiplying the starting difference of speed 
compared with [a] choice. And it's more scripter-firendly.

Guess I've learned my mistake, and hope I've made my point clear.
With respect, Bekim

>From: "David T. Lovering" <dlovering at gazos.com>
>Reply-To: "[JavaScript List]" <javascript at LaTech.edu>
>To: "[JavaScript List]" <javascript at LaTech.edu>
>Subject: Re: [Javascript] required entry field
>Date: Fri, 28 Mar 2003 11:15:41 -0700
>
>Hmmm... I'll take a stab at this.
>
>Inputs and other data-entry fields and widgets exist solely to collect 
>information from the remote user.  In order for them to work in this 
>capacity, they are collectively grouped together under the heading of a 
>'form', and are sent back to wherever the
>data processing and analysis is done (usually on a CGI/BIN formserver 
>somewhere).
>
>Many of these widgets don't work at all, or don't work properly UNLESS they 
>are in a form.  The general structure of a form is as follows:
>
>   <body>
>   ... yada yada
>     <form name='myForm' action='stuff that points to formserver' 
>type="CGI/BIN" method="POST">
>       <table>
>         ... tidy graphical arrangement of input devices
>       </table>
>     </form>
>   ... yada yada
>   </body>
>
>   Obviously, a lot more can be said.  If you want to use the form only for 
>the active data widgets and not to actually go anywhere, you can throw away 
>the type and method declaractions, and change the action as follows:
>
>   action='javascript:void(null)'
>
>   There, does that answer your question?
>
>   -- Dave Lovering
>
>BEKIM BACAJ wrote:
> >
> > Thanks, Rodney.
> > Now,I would like to ask a question on what 'form' stands for?
> > Also are you sugesting that my script will not work faster than your's, 
>or,
> > that my script will not work at all?
> >
> > Bekim
> >
> > >From: Rodney Myers <rodney at aflyingstart.net>
> > >Reply-To: "[JavaScript List]" <javascript at LaTech.edu>
> > >To: "[JavaScript List]" <javascript at LaTech.edu>
> > >Subject: Re: [Javascript] required entry field
> > >Date: Fri, 28 Mar 2003 10:11:19 +0000
> > >
> > >That would be .....
> > >
> > >function isValid(form) {  if(form.NeverBlank.value=='')
> > >   {
> > >    form.NeverBlank.focus()
> > >   }
> > >}
> > >
> > >hth
> > >Rodney
> > >
> > >
> > >
> > >BEKIM BACAJ wrote:
> > >
> > >>Einstein went mad when he heard that somebody wrote SF novel about a 
>man
> > >>who traveled with the speed of light and saw the batle of Waterloe, 
>for it
> > >>is insaine he yelled.
> > >>But 'you' can init the new battle at Waterlloe again
> > >>
> > >>function isValid() {    if(NeverBlank.value==''){
> > >>         NeverBlank.focus()
> > >>                 }
> > >>         }
> > >>
> > >>dejavoo - loops forever - if the user does not supply some chars!
> > >>
> > >
> > >--
> > >PS. I have just bought a licence for Mike Chen's
> > >BizAutomator. If you have to answer routine email queries from your 
>sites
> > >or mailings then
> > >you need this as much as I do. http://www.BizAutomator.com/rlbm51
> > >
> > >Rodney
> > >
> > >
> > >
> > >
> > >_______________________________________________
> > >Javascript mailing list
> > >Javascript at LaTech.edu
> > >https://lists.LaTech.edu/mailman/listinfo/javascript
> >
> > _________________________________________________________________
> > Protect your PC - get McAfee.com VirusScan Online
> > http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript


_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



More information about the Javascript mailing list