Results 1 to 8 of 8

Thread: Javascript grr!

  1. #1
    Hmmm bed
    Join Date
    Jul 2003
    Posts
    441
    Thanks
    5
    Thanked
    0 times in 0 posts

    Javascript grr!

    Hi, having loads of trouble with some javascript validation, nothing seems to be working for me!

    This is what has been set out as to what has to be done:

    • the length of the input is bigger than 0 but not greator than 14
    • only letters a-z "-" and space
    • the "-" and space must be entered
    • the "-" or space must not be either the first or last letter entered
    • "-" must not be the immediate neighbour to a space
    • "-" or space must not be adjacent


    the data is entered through a normal textfield.

    Any help would be greatly appreciated

    Thanks for your help

  2. #2
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Write a function to do the checks returning a boolean value to say if it's passed or not. Find the "-" if charAt(indexHere + 1) == a space then say no Pretty straight forward tbh. Think of it logically, break the task down into smaller tasks, what would you need to check etc?

    I'd loop through all the characters to check they're valid creating a function to return a boolean value dependant on if they're part of the alphabet, a "-" or a space.

    EDIT: Sounds similar to a module i studied with the OU a year ago, what's it for?

  3. #3
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    do a look for regular expressions..

    then I'd loop through as Kezzer mentions checking each requirement
    (\__/)
    (='.'=)
    (")_(")

  4. #4
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    I was going to say regex but i didn't know if they existed in JavaScript Plus, i've never really touched regex

  5. #5
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    Well, it's what regex was designed to do
    (\__/)
    (='.'=)
    (")_(")

  6. #6
    Hmmm bed
    Join Date
    Jul 2003
    Posts
    441
    Thanks
    5
    Thanked
    0 times in 0 posts
    cheers for the help guys, just had a look at a load of regexp stuff and it seems to be the way forward. Really struggling to get my head round comining all of the necessary expressions though!

    I've had alook at a few websites which were ok but nothing expecially helpful for the complete beginner, do you know of any good guides?

    Thanks for your help

  7. #7
    Pixel Abuser Spunkey's Avatar
    Join Date
    Nov 2003
    Location
    Milton Keynes
    Posts
    1,523
    Thanks
    0
    Thanked
    0 times in 0 posts
    hopefully this should be of some help.. http://www.webreference.com/js/column5/

  8. #8
    Hmmm bed
    Join Date
    Jul 2003
    Posts
    441
    Thanks
    5
    Thanked
    0 times in 0 posts
    yeah thats one of the websites i found first off, quite helpful, its just the operations of finding which chracters are next to which that i'm having trouble with

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Javascript help!
    By Stoo in forum Software
    Replies: 7
    Last Post: 23-02-2005, 11:20 AM
  2. grr double post
    By khizman in forum Graphics Cards
    Replies: 0
    Last Post: 01-02-2005, 07:57 PM
  3. Javascript problem
    By Korky in forum PC Hardware and Components
    Replies: 0
    Last Post: 03-04-2004, 12:58 AM
  4. Replies: 1
    Last Post: 14-08-2003, 03:32 PM

Posting Permissions

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