Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var someJSON = '<?php
- //php to escape the apostrophe's since people use them all teh time
- $retrack_jsondata = addcslashes($retrack_jsondata,'\'');
- echo $retrack_jsondata; ?>';
- <script type="text/javascript">
- jQuery(document).ready(function($){
- // front-end js to disallow user input of characters that break the JSON when it is trying to be parsed:
- $('#journal-entry').keypress(function(e) {
- // Check if the value of the input is valid
- console.log(e.keyCode );
- var valid
- switch(e.keyCode){
- case 34 : // "
- case 91 : // [
- case 92 : // \
- case 93 : // ]
- case 123 : // {
- case 124 : // |
- case 125 : // }
- valid = false;
- break;
- default:
- valid = true;
- break;
- }
- if (!valid)
- e.preventDefault();
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement