Real basic web page to clean a string for SQL insertion.

index.html 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="description" content="" />
  6. <meta name="author" content="Bryan Allred" />
  7. <title>Clean SQL String</title>
  8. <link href="http://plus.google.com/112949321083048638287" rel="publisher" />
  9. <style type="text/css">
  10. #browser
  11. {
  12. visibility: hidden;
  13. display: none;
  14. }
  15. .scribble
  16. {
  17. padding: 1em;
  18. width: 69em;
  19. height: 15em;
  20. }
  21. #bottom
  22. {
  23. }
  24. </style>
  25. <!--[if lt IE 9]>
  26. <style type="text/css">
  27. #browser
  28. {
  29. display: block;
  30. visibility: visible;
  31. }
  32. </style>
  33. <![endif]-->
  34. </head>
  35. <body>
  36. <!-- Warning to upgrade the browser -->
  37. <div id="browser">
  38. <h2>Dude, you are missing are the cool stuff!</h2>
  39. <p>We recommend upgrading to the latest <a href="http://ie.microsoft.com" title="Microsoft Internet Explorer">Internet Explorer</a>, <a href="http://chrome.google.com" title="Google Chrome">Google Chrome</a>, or <a href="http://mozilla.org/firefox" title="Firefox">Firefox</a>. If you are using IE 9 or later, make sure you turn off "Compatibility View".</p>
  40. </div>
  41. <a href="https://github.com/bmallred/cleansqlstring"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
  42. <h2>Dirty, filthy, ugly text</h2>
  43. <textarea id="top" class="scribble"></textarea>
  44. <h2>Clean, fresh, purty text</h2>
  45. <textarea id="bottom" class="scribble" readonly></textarea>
  46. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  47. <script>
  48. $(function () {
  49. function scrub() {
  50. var originalText = $("#top").val();
  51. var modifiedText = originalText.replace(/'/g, "''");
  52. $("#bottom").val(modifiedText);
  53. }
  54. $(document).on("change", "#top", function () {
  55. scrub();
  56. });
  57. $(document).on("keyup", "#top", function () {
  58. scrub();
  59. });
  60. $(document).on("focus", "#bottom", function () {
  61. $(this).select();
  62. })
  63. $(document).on("mouseup", "#bottom", function() {
  64. $(this).unbind("mouseup");
  65. return false;
  66. });
  67. })
  68. </script>
  69. </body>
  70. </html>