Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8943827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:53:00+00:00 2026-06-15T11:53:00+00:00

I have a multiline textbox in which I should not allow the user to

  • 0

I have a multiline textbox in which I should not allow the user to enter any HREF links.
So I am trying to string match using Regex as follows.
But I am not getting the error message. What am I doing wrong?

Regex strMatch = new Regex(@"^(?:(?:<a )?href|</a>)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
if (strMatch.IsMatch(EmailTextBox.Text.Trim()))
 {
   vsumPage.AddErrorMessage("Cannot enter links");
 }

Also the same check needs to work in JS too. But it it giving me some exception. not sure what am i doing wrong. Here is my JS function

function doPreview()
 {
  var getEncodedStr = encode("<%=EmailTextBox.ClientID%>"); 
  var strInvalid = "Email instructions cannot have links included";
  var str = getEncodedStr.match(/@"(?:<a )?href|</a>"/) ;
  if (str == null)
  {
    var targetURL = 'Preview.aspx?txtName=' + getEncodedStr ;
    window.open(targetURL, null, "height=700,width=600,dependent=yes,hotkey=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no");
    return false;
  }
  else
  {
   alert(strInvalid);
  }
}

Here’s the output that I am testing it with

Testing Testing <br/>
<b> Hello Testing </b> <br/>
<b> Testing 2000 character and link check </b> <br/>
<b> Hello </b> <a href="www.google.com">Click Me </a>

Updated again:
Tried this one as given below:
But it always comes to the alert “Test3 0” part…even when an

          function doPreview()
      {
          var getEncodedStr = encode("<%=EmailTextBox.ClientID%>"); 
          var strInvalid = "Email instructions cannot have links included";
          var checkCount = "0" ;
          alert("Test 1" + checkCount);
          if(/<\/[\s\S]?a\b/gm.test(decode(getEncodedStr)))
          { 
            checkCount = "1" ;
            alert("Test 2" + checkCount);
            alert((/<\/?a\b/.test(decode(getEncodedStr))));
            return false;
          }
          if (checkCount == "0")
          {                  
            alert("Test 3" + checkCount);
            var targetURL = 'EPreview.aspx?txtName=' + getEncodedStr ;
            window.open(targetURL, null, "height=700,width=600,dependent=yes,hotkey=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no");
            return false;
          }
      }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:53:01+00:00Added an answer on June 15, 2026 at 11:53 am

    The ^ asserts that this pattern occurs at the beginning of the string. Try removing it. Also you could probably change the pattern to:

    @"</?a\b"
    

    This will simply look for a <a or </a making sure that it is really an anchor tag, by using the word-boundary \b (which asserts that there is no letter or digit or underscore afterwards – but a space or > for example).

    If that does not do it, it would really help to see your actual input.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multiline textbox on which Ctrl+Enter triggers a specific action. Enter, obviously,
I have a multiline textbox which shouldn't accept alphabets, numbers, newline(enter key) and backspace.
I have a multiline TextBox for which any of the following inputs are valid:
I have TextBox (multiline) and Label in an UpdatePanel which I refresh with javascript
I have a Multiline Textbox . I donot want to let user type HTML
Greetings, I have a form where employees enter comments in a multiline textbox with
I have a normal textbox which multiline property is set to true and now
I have a multiline textbox in which i will be entering many email addresses.
In silverlight, I got a textbox which I want to be multiline and have
I'm trying to allow scrolling in a Multiline-TextBox even if the TextBox is set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.