Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    184
    Thanks
    140
    Thanked 0 Times in 0 Posts

    IIF and textboxes

    Hello,

    I need your help,

    I can seem to get this to work.

    I want to be able to use an IIF to check if a textbox empty ie.


    IIF(textbox1 = "" || textbox = null, "it is empty","it is not empty")

    This doesnt seem to be working.

    Any ideas?

    - Clueless =?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,799
    Thanks
    78
    Thanked 4,410 Times in 4,375 Posts
    There is no such thing as IIF in JavaScript.

    In fact, IIF doesn't even exist in VBScript.

    IIF exists in Visual Basic and in VBA (Visual Basic for Applications) and in VB.NET. So far as I know, those are the only places you find it.

    In JavaScript, perhaps you are looking for something like this:
    Code:
    var answer = (form.textbox1.value == "" || form.textbox1.vakue == null ) ? "it is empty" : "it is not empty";
    Maybe it is time to start here?? http://www.w3schools.com/js/
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,799
    Thanks
    78
    Thanked 4,410 Times in 4,375 Posts
    By the by, if indeed you are talking about <input name="textbox1" />, then the .value of such a field is *NEVER* empty. Form fields that have a .value property *always* return a STRING for that .value. Yes, it can be an empty string ("") but it can't be null.

    So it would be sufficient to code
    Code:
    var answer = ( myform.textbox1.value == "" ) ? "it is empty" : "it is not empty";
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •