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 7778863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:30:18+00:00 2026-06-01T18:30:18+00:00

I am making a form with an keyup() event: every character the user types

  • 0

I am making a form with an keyup() event: every character the user types is immediately displayed into another div on the same page.

It’s vulnerable to XSS. How can I secure it using jQuery?

Note: In my forms, I am using latin alphanumeric characters only, as well as commas, semi-colons, colons.

I have searched the “Reform” tool from OWASP but is there a way that’s better?

Thanks in advance. Regards

  • 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-01T18:30:19+00:00Added an answer on June 1, 2026 at 6:30 pm

    With the few details available: remember that you don’t have to use jQuery’s HTML “parsing” for everything. Instead of using .html(), use DOM manipulations and .text() (which are also usually faster). For example, this:

    $('#result').html('<span class="whatever">' + someInput + '</span>');
    

    would become this:

    $('#result').text($('<span>').addClass('whatever').text(someInput));
    

    If that’s not possible, you can also do flawless HTML escaping by setting with .text() and then fetching it with .html(). For example, this:

    var data = 'This text: **is bold**';
    
    $('#result').html(data.replace(/\*\*(.+?)\*\*/g, '<b>$1</b>'));
    

    would become this:

    var data = 'This text: **is bold**';
    
    $('#result').html(data.replace(/\*\*(.+?)\*\*/g, function(x) {
        return '<b>' + $('<div>').text(x).html() + '</b>';
    }));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a form and when a user hits submit, i want it to
I am asking the user to upload a file, through the following form making
I'm making a registration form and I want to check if the user has
I am making form validation and when user doesn't fill one of required fields
I am making a form. When I give the same height and width to
Short version: I want to trigger the Form_Load() event without making the form visible.
I am making a registration form. When a user is selecting a username I
Im making a form in ASP.Net MVC 3 C#. This particular page of the
I'm making a form for user registration. Here's what my template looks like: <h1>Register</h1>
I have a JSP page that needs to accept some info into a form,

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.