String in ASP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • F159753
    New Member
    • Apr 2008
    • 31

    String in ASP

    Hi,

    How could I find a special character like comma(,) for example in a string in ASp code? Then open an pop up window to show the error message: " The charactor comma(,) is not allowed in this text box!"

    Appreciated
    Fay
  • markrawlingson
    Recognized Expert Contributor
    • Aug 2007
    • 346

    #2
    It sounds like you would better off doing this with javascript. You can find a character or phrase in another string in ASP but you cannot generate any sort of alert message, only a textual error spat out on the page.

    [code=asp]

    sVariable = "Some string with a comma,"
    If InStr(sVariable ,",") > 0 Then
    Response.Write "You are not allowed any commas!"
    End If

    [/code]

    Javascript...

    [code=javascript]
    var sVariable = 'Some string with a comma,';
    if (sVariable.inde xOf(',') > 0) {
    alert('You are not allowed any commas!';
    }
    [/code]

    Sincerely,
    Mark

    Comment

    • F159753
      New Member
      • Apr 2008
      • 31

      #3
      Hi Mark,

      I truly appreciate your help.
      It worked.

      Thank you
      Fay

      Comment

      Working...