SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    check if none of array matches.......

    I'm using this function on a form, triggered by onkeyup.
    It's to allow users to create thier own descriptions, and the input is displayed automatically using innerHTML. This part of the function checks if the HTML tags are allowed through, I've got this far...

    allowedHTML=new Array("<br>","<b>","</b>","<i>","</i>")
    HTMLcount=allowedHTML.length
    function formcheck() {
    lettercount=document.formname.email.value.length
    HTMLcheck=""
    for(i=0;i<ltrcnt;i++){
    if(document.prsnlsd.email.value.charAt(i)=="<"){openat=i}
    if(document.prsnlsd.email.value.charAt(i)==">"){closeat=i+1
    for(j=openat;j<closeat;j++){
    HTMLcheck+=(document.formname.email.value.charAt(j))}
    for(k=0;k<HTMLcount;k++){
    if(HTMLcheck==allowedHTML[k]) return; else alert()}}}}}

    I want it to trigger if one of the "allowedHTML" isn't found by the time it's finished going through the array.

    Thanks

    ps...don't know about return; else
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  2. #2
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wouldn't it be easier to use regular expressions and then attempt to find each of the tags you're interested in?


Bookmarks

Posting Permissions

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