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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:19:12+00:00 2026-05-14T07:19:12+00:00

I posted a question yesterday, which I intend to get back to today however

  • 0

I posted a question yesterday, which I intend to get back to today however I wrote some JavaScript as a first line of prevention against XSS. However when testing this on my live server I catch some invalid input as the javascript catches the php section. My form uses post and php isn’t in my form items (i haven’t typed it in). Could this be picking up the form action or something? I’m baffeled, Any ideas

Here is my code, it is triggered on the submit button.

    function validateForBadNess(){

var theShit = new Array("*","^", "$", "(",")","{", "}","[", "]","\\", "|", "'","/","?",",","=",">","gt","lt", "<","script","`","´","php");
var tagName = new Array();

tagName[0] = "input";
tagName[1] = "select";
tagName[2] = "textbox";
tagName[3] = "textarea";

for (ms=0;ms<tagName.length;ms++){

 // loop through  the elements of the form
 var formItems = document.getElementsByTagName(tagName[ms]);

  for (var xs=0;xs<formItems.length;xs++){

   var thisString = formItems[xs].value;

   // loop through bad array
   for (zs in theShit){

    //alert(thisString + " " + thisString.indexOf(theShit[zs]))
    if(thisString.indexOf(theShit[zs]) >= 0){

    alert("Sorry but the following character: " + theShit[zs] + " is not permitted. Please omit it from your input.\nIf this is part of your password please contact us to heave your password reset.")
    return false;

    }

     }



  // loop for formitems 
  }

 // tagName toop
 }
// original condition
}
  • 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-05-14T07:19:13+00:00Added an answer on May 14, 2026 at 7:19 am

    What you do is totally unnecessary and useless in terms of protection against attacks. Any JavaScript based “protection” will be circumvented within seconds, and legitimate users will not be happy to be unable to use the $ sign for example. Always assume that any incoming data can have been tampered with.

    You need to be careful when outputting data on the server side. Use htmlspecialchars() on any incoming textual data. If you have incoming HTML you need “cleaned”, use HTML purifier as suggested by Sarfraz.

    Related SO reading:

    • What are the best practices for avoid xss attacks in a PHP site
    • XSS filtering function in PHP
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yesterday, I posted a question on some tips doing this Remote Client-Server Application in
this is my first posted question. I have a fairly complicated OQL query which
So I posted a question yesterday about placing some divs within a container so
I posted the following question yesterday but didn't get a helpful answer. May i
I posted a question up yesterday that asked for some help on an image
As a result of some helpful answers to a question I posted yesterday about
I posted this question yesterday evening, which has led me to discover a huge
I posted this question yesterday but received some valuable feedback that my post left
I posted a question yesterday which was answered, sadly though I now have a
(hello dr.Nick) :) So I posted a question yesterday about a content loader plugin

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.