Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. string testing fails

string testing fails

Scheduled Pinned Locked Moved JavaScript
helptestingbeta-testing
3 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SummerBulb
    wrote on last edited by
    #1

    :confused: This code:

    var allowedChars = "qwertyuiopasdfghjklzxcvbnm1234567890/'קראטוןםפךלחיעכגדשזסבהנמצ";

    var card = document.getElementById("cardid").value;
    for (i=0; i< 10; i++)
        if (allowedChars.indexOf(card\[i\]) == -1)
        {
            alert("Error");
            return true;
        }
    

    is supposed to check an input string. For an unknown reason, it works on ff 3.6.10, but not on IE 7. Help will be highly appreciated. Thanks, Summer Bulb.

    N M 2 Replies Last reply
    0
    • S SummerBulb

      :confused: This code:

      var allowedChars = "qwertyuiopasdfghjklzxcvbnm1234567890/'קראטוןםפךלחיעכגדשזסבהנמצ";

      var card = document.getElementById("cardid").value;
      for (i=0; i< 10; i++)
          if (allowedChars.indexOf(card\[i\]) == -1)
          {
              alert("Error");
              return true;
          }
      

      is supposed to check an input string. For an unknown reason, it works on ff 3.6.10, but not on IE 7. Help will be highly appreciated. Thanks, Summer Bulb.

      N Offline
      N Offline
      NeverHeardOfMe
      wrote on last edited by
      #2

      I don't think you can use

      card[i]

      to refernce the i'th character in a string this way, not in IE anyway. Try

      card.charAt(i)

      instead.

      1 Reply Last reply
      0
      • S SummerBulb

        :confused: This code:

        var allowedChars = "qwertyuiopasdfghjklzxcvbnm1234567890/'קראטוןםפךלחיעכגדשזסבהנמצ";

        var card = document.getElementById("cardid").value;
        for (i=0; i< 10; i++)
            if (allowedChars.indexOf(card\[i\]) == -1)
            {
                alert("Error");
                return true;
            }
        

        is supposed to check an input string. For an unknown reason, it works on ff 3.6.10, but not on IE 7. Help will be highly appreciated. Thanks, Summer Bulb.

        M Offline
        M Offline
        moocr com
        wrote on last edited by
        #3

        why you do not use regular expression?

        //sorry, but I can not input the rest chars.
        var reg=/[qwertyuiopasdfghjklzxcvbnm1234567890]{10}/gi;

        if(!reg.test(document.getElementById("cardId").value)){
        alert("Error");
        }

        see more javascript skill, just click moocr.com

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups