how to include " in my validation script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bartosz Wegrzyn

    how to include " in my validation script

    I wrote this function to validate the name.


    //test name for illegal characters
    var illegal = "0123456789!@#$ %^&*()-=_+[]\{}|;':,./?><";
    for (var i=0;i<strng.len gth;i++) {
    temp = strng.substring (i,i+1);

    if (illegal.indexO f(temp) != -1 && strng != "")

    {
    error = "The name contains illegal characters.\n";
    }

    How can I include " character in my 'illegal' string.
    Are there any other ways to tell string 'illegal' to include only letters.

    I am not familiar with this.
    If you know any links plesase give it to me.

    Thanks


  • VK

    #2
    Re: how to include &quot; in my validation script

    function validate (thisString) {
    var re = /[^A-Za-z]/g; // creating a regular expression
    if (re.test(thisSt ring)) {
    error = "The name contains illegal characters.";
    }
    else {
    // everything's fine
    }
    }



    Bartosz Wegrzyn <blwegrzyn@lexo n.ws> wrote in message
    news:gQI9b.5512 $nQ.1658143@new ssvr28.news.pro digy.com...[color=blue]
    > I wrote this function to validate the name.
    >
    >
    > //test name for illegal characters
    > var illegal = "0123456789!@#$ %^&*()-=_+[]\{}|;':,./?><";
    > for (var i=0;i<strng.len gth;i++) {
    > temp = strng.substring (i,i+1);
    >
    > if (illegal.indexO f(temp) != -1 && strng != "")
    >
    > {
    > error = "The name contains illegal characters.\n";
    > }
    >
    > How can I include " character in my 'illegal' string.
    > Are there any other ways to tell string 'illegal' to include only letters.
    >
    > I am not familiar with this.
    > If you know any links plesase give it to me.
    >
    > Thanks
    >
    >[/color]


    Comment

    • Bartosz Wegrzyn

      #3
      Re: how to include &quot; in my validation script

      thanks

      I found this



      "VK" <schools_ring@y ahoo.com> wrote in message
      news:3f677239$0 $30070$9b622d9e @news.freenet.d e...[color=blue]
      > function validate (thisString) {
      > var re = /[^A-Za-z]/g; // creating a regular expression
      > if (re.test(thisSt ring)) {
      > error = "The name contains illegal characters.";
      > }
      > else {
      > // everything's fine
      > }
      > }
      >
      >
      >
      > Bartosz Wegrzyn <blwegrzyn@lexo n.ws> wrote in message
      > news:gQI9b.5512 $nQ.1658143@new ssvr28.news.pro digy.com...[color=green]
      > > I wrote this function to validate the name.
      > >
      > >
      > > //test name for illegal characters
      > > var illegal = "0123456789!@#$ %^&*()-=_+[]\{}|;':,./?><";
      > > for (var i=0;i<strng.len gth;i++) {
      > > temp = strng.substring (i,i+1);
      > >
      > > if (illegal.indexO f(temp) != -1 && strng != "")
      > >
      > > {
      > > error = "The name contains illegal characters.\n";
      > > }
      > >
      > > How can I include " character in my 'illegal' string.
      > > Are there any other ways to tell string 'illegal' to include only[/color][/color]
      letters.[color=blue][color=green]
      > >
      > > I am not familiar with this.
      > > If you know any links plesase give it to me.
      > >
      > > Thanks
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...