validation has syntax errors [correction]

Discussion in 'Javascript' started by jr, Aug 3, 2010.

  1. jr

    jr Guest

    This one seems like it should work, I don't get syntax errors but the
    problem is it doesn't work.
    The script doesn't validate anything. If it is correct then something
    else is wrong otherwise it is not validating
    any of the values, thanks,

    function checkscript() {
    if ( search_bu.value && search_error_flag) {
    if ( zoneid.value && !zonenum.value ) {return 1 }

    }

    return 0;
    jr, Aug 3, 2010
    #1
    1. Advertising

  2. On 03/08/10 07:13, jr wrote:

    > function checkscript() {
    > if ( search_bu.value && search_error_flag) {
    > if ( zoneid.value && !zonenum.value ) {return 1 }
    > }
    >
    > return 0;


    I hope you had a "}" after the return 0?

    I'm sure you're fully aware, having been told many times, that you can't
    just use the field name or id to identify a field in javascript. You
    have to translate that information somewhere into something the code
    understands.

    In fact, this is a fundamental concept that you should understand by now.

    Irrespective of whether the logical flow of your code works (and as I
    don't fully understand what you're trying to check, I can't verify
    whether it will or not) I have no idea what the one variable and three
    objects you're testing here are.

    There are two ways to address objects relating to input elements in a
    form from within javascript. One, which some people now consider
    outdated, is as a named property of the parent form object, and the
    other is using the element id. If using the named property of form
    method, then you also need to identify the form, either as a member of
    the document's forms collection, or as a named property of the document.

    I have seen code that combines using the id of the form and then
    referring to an input as a named property of that form, which is to me
    illogical, as in my opinion if you're going to use element id attributes
    you might as well use id at the input element level.

    Once you have identified the object that relates to an input element on
    a form, there is as one and only one common way to get the content of
    that element.

    Rgds

    Denis McMahon
    Denis McMahon, Aug 3, 2010
    #2
    1. Advertising

  3. jr

    jr Guest

    On Aug 3, 6:44 am, Denis McMahon <>
    wrote:
    > On 03/08/10 07:13, jr wrote:
    >
    > > function checkscript() {
    > >    if ( search_bu.value  && search_error_flag) {
    > >      if ( zoneid.value && !zonenum.value ) {return 1 }
    > >    }

    >
    > >  return 0;

    >
    > I hope you had a "}" after the return 0?
    >
    > I'm sure you're fully aware, having been told many times, that you can't
    > just use the field name or id to identify a field in javascript. You
    > have to translate that information somewhere into something the code
    > understands.
    >
    > In fact, this is a fundamental concept that you should understand by now.
    >
    > Irrespective of whether the logical flow of your code works (and as I
    > don't fully understand what you're trying to check, I can't verify
    > whether it will or not) I have no idea what the one variable and three
    > objects you're testing here are.
    >
    > There are two ways to address objects relating to input elements in a
    > form from within javascript. One, which some people now consider
    > outdated, is as a named property of the parent form object, and the
    > other is using the element id. If using the named property of form
    > method, then you also need to identify the form, either as a member of
    > the document's forms collection, or as a named property of the document.
    >
    > I have seen code that combines using the id of the form and then
    > referring to an input as a named property of that form, which is to me
    > illogical, as in my opinion if you're going to use element id attributes
    > you might as well use id at the input element level.
    >
    > Once you have identified the object that relates to an input element on
    > a form, there is as one and only one common way to get the content of
    > that element.
    >
    > Rgds
    >
    > Denis McMahon


    okay, that makes sense so if I do this ele.search_bu.value, I should
    do ele= document.form[0], I think that was what was missing,
    thanks, you are right I should have seen it.
    jr, Aug 3, 2010
    #3
  4. jr

    jr Guest

    On Aug 3, 6:44 am, Denis McMahon <>
    wrote:
    > On 03/08/10 07:13, jr wrote:
    >
    > > function checkscript() {
    > >    if ( search_bu.value  && search_error_flag) {
    > >      if ( zoneid.value && !zonenum.value ) {return 1 }
    > >    }

    >
    > >  return 0;

    >
    > I hope you had a "}" after the return 0?
    >
    > I'm sure you're fully aware, having been told many times, that you can't
    > just use the field name or id to identify a field in javascript. You
    > have to translate that information somewhere into something the code
    > understands.
    >
    > In fact, this is a fundamental concept that you should understand by now.
    >
    > Irrespective of whether the logical flow of your code works (and as I
    > don't fully understand what you're trying to check, I can't verify
    > whether it will or not) I have no idea what the one variable and three
    > objects you're testing here are.
    >
    > There are two ways to address objects relating to input elements in a
    > form from within javascript. One, which some people now consider
    > outdated, is as a named property of the parent form object, and the
    > other is using the element id. If using the named property of form
    > method, then you also need to identify the form, either as a member of
    > the document's forms collection, or as a named property of the document.
    >
    > I have seen code that combines using the id of the form and then
    > referring to an input as a named property of that form, which is to me
    > illogical, as in my opinion if you're going to use element id attributes
    > you might as well use id at the input element level.
    >
    > Once you have identified the object that relates to an input element on
    > a form, there is as one and only one common way to get the content of
    > that element.
    >
    > Rgds
    >
    > Denis McMahon


    I tried it like this and it still doesn't fire. there are 4 fields in
    a search form. The first 2 required. The zonenm is only required if
    there is no zoneid. IT seems like it should work. Rgds, Janis
    function checkscript() {
    // If bu and error_flag have a value return 0, if zoneid has a value
    without zonenm proceed to next check
    var ele=document.forms[0];
    if (ele.search_bu.value && ele.search_error_flag.value ) {
    // If zoneid has a value and zonenm does not have a value
    return false
    if (ele.search_zoneid.value && !ele.search_zonenm.value) {
    return 1;
    } else {
    // if zoneid doesn't have a value, or
    // if both zoneid and zonenm have values
    return 0;
    }
    // If either bu or error_flag (or both) don't have a value
    } else {
    return 1;
    }
    }

    </script>
    Regards,
    Janis
    jr, Aug 3, 2010
    #4
  5. Am 2010-08-03 17:34, schrieb jr:

    > okay, that makes sense so if I do this ele.search_bu.value, I should
    > do ele= document.form[0], I think that was what was missing,


    document.form*s*[0].elements["search_blu"];

    > thanks, you are right I should have seen it.


    Erm...

    Gregor
    Gregor Kofler, Aug 3, 2010
    #5
  6. On Aug 3, 2:44 pm, Denis McMahon wrote:
    > On 03/08/10 07:13, jr wrote:
    >
    >> function checkscript() {
    >> if ( search_bu.value && search_error_flag) {
    >> if ( zoneid.value && !zonenum.value ) {return 1 }
    >> }

    >
    >> return 0;

    >
    > I hope you had a "}" after the return 0?
    >
    > I'm sure you're fully aware, having been told many times, that
    > you can't just use the field name or id to identify a field
    > in javascript.


    One of the main reasons that people are continually told that they
    shouldn't use a field's name or ID to identify a filed is that in many
    cases you can, and so for some value of 'works' it does 'work'. The
    problem with it is that there are some environments/contexts were it
    won't work and so is neither reliable nor cross-browser.

    > You have to translate that information somewhere into something
    > the code understands.
    >
    > In fact, this is a fundamental concept that you should
    > understand by now.
    >
    > Irrespective of whether the logical flow of your code
    > works (and as I don't fully understand what you're trying
    > to check, I can't verify whether it will or not) I have no
    > idea what the one variable and three objects you're testing
    > here are.


    No, the javascript code without the mark-up that creates the DOM with
    which it interacts has relatively little meaning.

    > There are two ways to address objects relating to input
    > elements in a form from within javascript.


    I can think of at least 6 obvious ways, and that means there will
    probably be a dozen more.

    > One, which some people now consider outdated, is as a named
    > property of the parent form object,
    > and the other is using the element id.


    That would be a vague distinction as a property of the FORM element
    may exist with a name that corresponds with the ID of the element.
    Presumably you mean accessing the form control using its ID with -
    documentGetElementById -.

    The W3C HTML DOM offers the - elements - property of the FORM element
    as a collection of contained form control elements, that can be
    integer indexed or referenced by name and/or ID. Being both DOM
    standard and back-compatible with every scriptable web browser that
    has ever known what a form is, this should be the preferred method of
    accessing form controls.

    > If using the named property of form method, then you also
    > need to identify the form,
    > either as a member of the document's forms collection, or
    > as a named property of the document.


    From a FORM element's - onsubmit - listener the form can be
    anonymously referenced using the - this - keyword, and from the
    intrinsic event listeners of form controls elements the - this.form -
    will refer to the containing FROM element. Generally form validation
    will involve one of these so there is normally no reason for the form
    having a name/ID or there being any interest/reliance on the FORM's
    index in the - document.forms - collection.

    > I have seen code that combines using the id of the form
    > and then referring to an input as a named property of that
    > form, which is to me illogical,


    I don't see why. Strict HTML 4 does not allow FORM elements to have
    NAME attributes, so there they cannot be referenced by name, and from
    controls need to have NAME attributes if they are to be
    'successful' (their values submitted to the server) so without some
    other need (such as cross-referencing LABEL elements) adding ID
    attributes to them could be superfluous.

    > as in my opinion if you're going to use element id
    > attributes you might as well use id at the input element
    > level.


    An ID should be unique to the document, but a document could contain
    multiple forms, and different forms may contain fields that
    (logically) should have the same name.

    > Once you have identified the object that relates to an
    > input element on a form, there is as one and only one
    > common way to get the content of that element.


    At least if you disregard radio buttons and checkboxes (neither of
    which have "content" and their - value - properties are rarely of
    primary interest while validating).

    Richard.
    Richard Cornford, Aug 3, 2010
    #6
  7. jr

    jr Guest

    On Aug 3, 10:00 am, Richard Cornford <>
    wrote:
    > On Aug 3, 2:44 pm, Denis McMahon wrote:
    >
    > > On 03/08/10 07:13, jr wrote:

    >
    > >> function checkscript() {
    > >>    if ( search_bu.value  && search_error_flag) {
    > >>      if ( zoneid.value && !zonenum.value ) {return 1 }
    > >>    }

    >
    > >>  return 0;

    >
    > > I hope you had a "}" after the return 0?

    >
    > > I'm sure you're fully aware, having been told many times, that
    > > you can't just use the field name or id to identify a field
    > > in javascript.

    >
    > One of the main reasons that people are continually told that they
    > shouldn't use a field's name or ID to identify a filed is that in many
    > cases you can, and so for some value of 'works' it does 'work'. The
    > problem with it is that there are some environments/contexts were it
    > won't work and so is neither reliable nor cross-browser.
    >
    > > You have to translate that information somewhere into something
    > > the code understands.

    >
    > > In fact, this is a fundamental concept that you should
    > > understand by now.

    >
    > > Irrespective of whether the logical flow of your code
    > > works (and as I don't fully understand what you're trying
    > > to check, I can't verify whether it will or not) I have no
    > > idea what the one variable and three objects you're testing
    > > here are.

    >
    > No, the javascript code without the mark-up that creates the DOM with
    > which it interacts has relatively little meaning.
    >
    > > There are two ways to address objects relating to input
    > > elements in a form from within javascript.

    >
    > I can think of at least 6 obvious ways, and that means there will
    > probably be a dozen more.
    >
    > > One, which some people now consider outdated, is as a named
    > > property of the parent form object,
    > > and the other is using the element id.

    >
    > That would be a vague distinction as a property of the FORM element
    > may exist with a name that corresponds with the ID of the element.
    > Presumably you mean accessing the form control using its ID with -
    > documentGetElementById -.
    >
    > The W3C HTML DOM offers the - elements - property of the FORM element
    > as a collection of contained form control elements, that can be
    > integer indexed or referenced by name and/or ID. Being both DOM
    > standard and back-compatible with every scriptable web browser that
    > has ever known what a form is, this should be the preferred method of
    > accessing form controls.
    >
    > > If using the named property of form method, then you also
    > > need to identify the form,
    > > either as a member of the document's forms collection, or
    > > as a named property of the document.

    >
    > From a FORM element's - onsubmit - listener the form can be
    > anonymously referenced using the - this - keyword, and from the
    > intrinsic event listeners of form controls elements the - this.form -
    > will refer to the containing FROM element. Generally form validation
    > will involve one of these so there is normally no reason for the form
    > having a name/ID or there being any interest/reliance on the FORM's
    > index in the - document.forms - collection.
    >
    > > I have seen code that combines using the id of the form
    > > and then referring to an input as a named property of that
    > > form, which is to me illogical,

    >
    > I don't see why. Strict HTML 4 does not allow FORM elements to have
    > NAME attributes, so there they cannot be referenced by name, and from
    > controls  need to have NAME attributes if they are to be
    > 'successful' (their values submitted to the server) so without some
    > other need (such as cross-referencing LABEL elements) adding ID
    > attributes to them could be superfluous.
    >
    > > as in my opinion if you're going to use element id
    > > attributes you might as well use id at the input element
    > > level.

    >
    > An ID should be unique to the document, but a document could contain
    > multiple forms, and different forms may contain fields that
    > (logically) should have the same name.
    >
    > > Once you have identified the object that relates to an
    > > input element on a form, there is as one and only one
    > > common way to get the content of that element.

    >
    > At least if you disregard radio buttons and checkboxes (neither of
    > which have "content" and their - value - properties are rarely of
    > primary interest while validating).
    >
    > Richard.


    thanks,
    jr, Aug 3, 2010
    #7
  8. On 03/08/10 16:44, jr wrote:

    > I tried it like this and it still doesn't fire. there are 4 fields in
    > a search form. The first 2 required. The zonenm is only required if
    > there is no zoneid. IT seems like it should work. Rgds, Janis


    > function checkscript() {
    > // If bu and error_flag have a value return 0,
    > // if zoneid has a value without zonenm proceed
    > // to next check
    > var ele=document.forms[0];
    > if (ele.search_bu.value && ele.search_error_flag.value ) {
    > // If zoneid has a value and zonenm does
    > // not have a value return false
    > if (ele.search_zoneid.value && !ele.search_zonenm.value) {
    > return 1;
    > } else {
    > // if zoneid doesn't have a value, or
    > // if both zoneid and zonenm have values
    > return 0;
    > }
    > // If either bu or error_flag (or both) don't have a value
    > } else {
    > return 1;
    > }
    > }


    Ok, the function as presented appears, as far as I can tell, to match
    the comments associated with it.

    How are you calling the function? I would look at the opening tag of the
    form element, and the submit element inside the form.

    Are there any other forms on the page? If so, are you referring to the
    correct form? It might be better, in the case of multiple forms, to use
    a more explicit identification of the form. At present, you are assuming
    that the form is form[0]. It may not be safe, if there are multiple
    forms, to assume that that the forms array holds them in a predefined order.

    If you give the form a name, you can use that name in your definition of
    "ele".

    Rgds

    Denis McMahon
    Denis McMahon, Aug 3, 2010
    #8
  9. jr

    jr Guest

    On Aug 3, 10:51 am, Denis McMahon <>
    wrote:
    > On 03/08/10 16:44, jr wrote:
    >
    >
    >
    >
    >
    > > I tried it like this and it still doesn't fire.  there are 4 fields in
    > > a search form.  The first 2 required.  The zonenm is only required if
    > > there is no zoneid.  IT seems like it should work.  Rgds, Janis
    > > function checkscript() {
    > > // If bu and error_flag have a value return 0,
    > > // if zoneid has a value without zonenm proceed
    > > // to next check
    > >    var ele=document.forms[0];
    > >     if (ele.search_bu.value  && ele.search_error_flag.value ) {
    > >       // If zoneid has a value and zonenm does
    > >       // not have a value return false
    > >       if (ele.search_zoneid.value && !ele.search_zonenm.value) {
    > >         return 1;
    > >       } else {
    > >         // if zoneid doesn't have a value, or
    > >         // if both zoneid and zonenm have values
    > >         return 0;
    > >       }
    > >     // If either bu or error_flag (or both) don't have a value
    > >     } else {
    > >       return 1;
    > >     }
    > >   }

    >
    > Ok, the function as presented appears, as far as I can tell, to match
    > the comments associated with it.
    >
    > How are you calling the function? I would look at the opening tag of the
    > form element, and the submit element inside the form.
    >
    > Are there any other forms on the page? If so, are you referring to the
    > correct form? It might be better, in the case of multiple forms, to use
    > a more explicit identification of the form. At present, you are assuming
    > that the form is form[0]. It may not be safe, if there are multiple
    > forms, to assume that that the forms array holds them in a predefined order.
    >
    > If you give the form a name, you can use that name in your definition of
    > "ele".
    >
    > Rgds
    >
    > Denis McMahon


    This is the submit button in the view source:
    <td colspan='13' align='center'><input type='submit' name='submit1'
    value = ' Search'>

    This is the form post in view source:
    <form action='/tools/cart_inventory/cart_order_review.php'
    onSubmit='return checkscript();' method='post'>

    there is only one submit button, a search form. There are two sql's in
    an if/else but only one search form and one result set. I called it
    submit1 but it doesn't work if I call it just submit. rgds, Janis
    jr, Aug 3, 2010
    #9
  10. jr

    jr Guest

    On Aug 3, 10:51 am, Denis McMahon <>
    wrote:
    > On 03/08/10 16:44, jr wrote:
    >
    >
    >
    >
    >
    > > I tried it like this and it still doesn't fire.  there are 4 fields in
    > > a search form.  The first 2 required.  The zonenm is only required if
    > > there is no zoneid.  IT seems like it should work.  Rgds, Janis
    > > function checkscript() {
    > > // If bu and error_flag have a value return 0,
    > > // if zoneid has a value without zonenm proceed
    > > // to next check
    > >    var ele=document.forms[0];
    > >     if (ele.search_bu.value  && ele.search_error_flag.value ) {
    > >       // If zoneid has a value and zonenm does
    > >       // not have a value return false
    > >       if (ele.search_zoneid.value && !ele.search_zonenm.value) {
    > >         return 1;
    > >       } else {
    > >         // if zoneid doesn't have a value, or
    > >         // if both zoneid and zonenm have values
    > >         return 0;
    > >       }
    > >     // If either bu or error_flag (or both) don't have a value
    > >     } else {
    > >       return 1;
    > >     }
    > >   }

    >
    > Ok, the function as presented appears, as far as I can tell, to match
    > the comments associated with it.
    >
    > How are you calling the function? I would look at the opening tag of the
    > form element, and the submit element inside the form.
    >
    > Are there any other forms on the page? If so, are you referring to the
    > correct form? It might be better, in the case of multiple forms, to use
    > a more explicit identification of the form. At present, you are assuming
    > that the form is form[0]. It may not be safe, if there are multiple
    > forms, to assume that that the forms array holds them in a predefined order.
    >
    > If you give the form a name, you can use that name in your definition of
    > "ele".
    >
    > Rgds
    >
    > Denis McMahon


    I also tried onClick,
    jr, Aug 3, 2010
    #10
  11. jr

    Tim Streater Guest

    In article
    <>,
    jr <> wrote:

    > there is only one submit button, a search form. There are two sql's in
    > an if/else but only one search form and one result set. I called it
    > submit1 but it doesn't work if I call it just submit. rgds, Janis


    Can you explain what you mean by: "There are two sql's in an if/else but
    only one search form and one result set." Where are they?

    --
    Tim

    "That excessive bail ought not to be required, nor excessive fines imposed,
    nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
    Tim Streater, Aug 3, 2010
    #11
  12. On 03/08/10 20:06, jr wrote:

    > This is the submit button in the view source:
    > <td colspan='13' align='center'><input type='submit' name='submit1'
    > value = ' Search'>
    >
    > This is the form post in view source:
    > <form action='/tools/cart_inventory/cart_order_review.php'
    > onSubmit='return checkscript();' method='post'>


    I believe that onsubmit expects a boolean value, but you are returning a
    numeric value. Is it possible that your return values are not being
    interpreted as you expect?

    Perhaps it would be better to actually return true or false from your
    validation function, instead of 1 or 0.

    Rgds

    Denis McMahon
    Denis McMahon, Aug 3, 2010
    #12
  13. jr

    jr Guest

    On Aug 3, 2:31 pm, Denis McMahon <>
    wrote:
    > On 03/08/10 20:06, jr wrote:
    >
    > > This is the submit button in the view source:
    > > <td colspan='13' align='center'><input type='submit' name='submit1'
    > > value = ' Search'>

    >
    > > This is the form post in view source:
    > > <form action='/tools/cart_inventory/cart_order_review.php'
    > > onSubmit='return checkscript();'  method='post'>

    >
    > I believe that onsubmit expects a boolean value, but you are returning a
    > numeric value. Is it possible that your return values are not being
    > interpreted as you expect?
    >
    > Perhaps it would be better to actually return true or false from your
    > validation function, instead of 1 or 0.
    >
    > Rgds
    >
    > Denis McMahon


    I will try that thanks,
    jr, Aug 4, 2010
    #13
  14. jr

    jr Guest

    On Aug 3, 12:26 pm, Tim Streater <> wrote:
    > In article
    > <>,
    >
    >  jr <> wrote:
    > > there is only one submit button, a search form. There are two sql's in
    > > an if/else but only one search form and one result set. I called it
    > > submit1 but it doesn't work if I call it just submit.  rgds, Janis

    >
    > Can you explain what you mean by: "There are two sql's in an if/else but
    > only one search form and one result set." Where are they?
    >
    > --
    > Tim
    >
    > "That excessive bail ought not to be required, nor excessive fines imposed,
    > nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689


    Sure it was a cross over from mysql/php I probably didn't need to
    mention it here on this list but there is an if/then that pulls
    different rows of records depending on the values selected to search
    on in the search box. It so happens if there is an error then there
    is no match key and the sql is only on the one table of records so it
    displays different results if there is amatch key then all the columns
    are returned.
    jr, Aug 4, 2010
    #14
  15. jr <> writes:

    > This one seems like it should work, I don't get syntax errors but the
    > problem is it doesn't work.


    "Doesn't work" isn't a very good error description.
    I'm going to harp on this again at the end, please stay tuned :)

    > The script doesn't validate anything. If it is correct then something
    > else is wrong otherwise it is not validating
    > any of the values, thanks,
    >
    > function checkscript() {
    > if ( search_bu.value && search_error_flag) {
    > if ( zoneid.value && !zonenum.value ) {return 1 }
    >
    > }
    >
    > return 0;


    There is far too little context here to say what's not working.
    We can't ses what the variables "search_bu", "search_error_flag" etc.
    refer to (if anything).

    I'm assuming this is a form validation. In that case, I recommend
    passing the form as a parameter to the function and make explicit
    lookups in its elements array. E.g.

    <form action="..." onsubmit="return checkscript(this);">
    <input type="text" name="search_bu" ...
    </form>
    <script>
    function checkscript(form) {
    var elems = form.elements;
    return elems['search_bu'].value != ""
    && elems['search_error_flag'].checked
    && elems['zoneid'].value != ""
    && Number(elems['zonenum'].value) != 0;
    // You must return *false* to cancel the submit,
    // 0 isn't good enough.
    }
    </script>

    Here I'm guessing that the input control with name 'search_error_flag'
    is a checkbox, and the rest are text inputs of some sort, with the
    content of 'zonenum' being interpreted as a number.



    In general (and that's not just for you), to get good help with a
    problem you need to provide enough information for the reader to
    reproduce, recognize and repair the problem. That means:

    Reproduce: What did you do - all the code necessary to try it, but
    please cut it down to a small self-contained example that still
    exhibits the problem. If it's more than a few lines, a link to a
    page is also good.
    Recognize: What happened - be specific. "Nothing happened" isn't
    as good as "there was no visible change on the page".
    Repair: What did you expect to happen - again, be specific.

    Without either of these, you will have people either guessing (which
    is likely to be a waste of both their time and your chance of getting
    a good answer) or saying an ironic "You did something wrong, try
    something else".

    Best of luck
    /L
    --
    Lasse Reichstein Holst Nielsen
    'Javascript frameworks is a disruptive technology'
    Lasse Reichstein Nielsen, Aug 4, 2010
    #15
  16. In comp.lang.javascript message <3ade0983-7b2e-4351-87f9-4cb9b5f51831@f6
    g2000pro.googlegroups.com>, Tue, 3 Aug 2010 08:44:02, jr
    <> posted:

    >
    >I tried it like this and it still doesn't fire. there are 4 fields in
    >a search form. The first 2 required. The zonenm is only required if
    >there is no zoneid. IT seems like it should work. Rgds, Janis
    >function checkscript() {
    >// If bu and error_flag have a value return 0, if zoneid has a value
    >without zonenm proceed to next check
    > var ele=document.forms[0];
    > if (ele.search_bu.value && ele.search_error_flag.value ) {
    > // If zoneid has a value and zonenm does not have a value
    >return false
    > if (ele.search_zoneid.value && !ele.search_zonenm.value) {
    > return 1;
    > } else {
    > // if zoneid doesn't have a value, or
    > // if both zoneid and zonenm have values
    > return 0;
    > }
    > // If either bu or error_flag (or both) don't have a value
    > } else {
    > return 1;
    > }
    > }
    >
    > </script>



    If you want to make helping you easy, you MUST post easily-readable,
    easily-testable code.

    Leave a gap between code and non-code.

    Don't post a mismatched </script> or similar.

    Use true & false for Booleans, not 1 & 0.

    DO NOT ALLOW your posting agent to line-wrap code; preferably write code
    with lines of 72 characters or fewer. Posted code must be RECEIVED as
    executable code.

    And "else" is rarely needed after "return", and IMHO should not be used
    where not needed.

    Read the FAQ.

    --
    (c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE8 FF3 Op10 Sf4 Cr4
    news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
    Dr J R Stockton, Aug 4, 2010
    #16
  17. In comp.lang.javascript message <4c581d56$0$2913$>,
    Tue, 3 Aug 2010 14:44:29, Denis McMahon <
    m> posted:

    >
    >There are two ways to address objects relating to input elements in a
    >form from within javascript. One, which some people now consider
    >outdated, is as a named property of the parent form object, and the
    >other is using the element id. If using the named property of form
    >method, then you also need to identify the form, either as a member of
    >the document's forms collection, or as a named property of the document.
    >



    To me, using Form.name seems far more structured than using an ID.

    Query : is there an array or collection of IDs, as there is of anchors?
    None of my guessed identifiers for it was accepted, and without an
    identifier it's hard to look up,

    --
    (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 7.
    Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
    Command-prompt MiniTrue is useful for viewing/searching/altering files. Free,
    DOS/Win/UNIX now 2.0.6; see <URL:http://www.merlyn.demon.co.uk/pc-links.htm>.
    Dr J R Stockton, Aug 7, 2010
    #17
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    926
    Mark Goldin
    Jan 17, 2004
  2. =?Utf-8?B?ZGh1cndpdHo=?=
    Replies:
    1
    Views:
    443
    Teemu Keiski
    Apr 10, 2004
  3. yawnmoth
    Replies:
    97
    Views:
    4,651
    Bent C Dalager
    Feb 27, 2009
  4. jr

    validation has syntax errors

    jr, Aug 3, 2010, in forum: Javascript
    Replies:
    16
    Views:
    154
    Thomas 'PointedEars' Lahn
    Aug 4, 2010
  5. thedarkman

    correction brings more errors

    thedarkman, Mar 24, 2012, in forum: HTML
    Replies:
    8
    Views:
    562
    Jonathan N. Little
    Mar 25, 2012
Loading...

Share This Page