JavaScript - Tinymce Wont Allow Certain Characters
Hi
I have a CMS system using Tinymce and after making some alterations noticed the updates weren't showing up. After much messing (sql, set up etc) I started to delete the content bits at a time and came to the conclusion that is was the character ' as in what's any ideas why this is and how to solve it i'm thinking its due to php code! Cheers Similar TutorialsHello I'm trying to get the values from the TinyMCE with a javascript in to the url but it's not working, can any one help me? The script has been simplified to better understand mu problem, I can get all the rest of the form fields in to the url but not the textarea, it's a bit stubborn. Code: <script language=JavaScript> function reload(form) { for(var i=0; i < form.adtype.length; i++){ if(form.adtype[i].checked) var v1=form.adtype[i].value; var v2=form.title.value ; var v3=form.price.value ; var v4=form.subcat.value ; var v5=form.description.value ; <!-- TinyMCE description Variable-->// } var val=form.cat.options[form.cat.options.selectedIndex].value; self.location='new_ad.php?cat=' + val + '&adtype=' + v1 + '&title=' + v2 + '&price=' + v3 + '&subcat=' + v4 + '&description=' + v5; } </script> <?php $Description=$_GET['description']; echo "<label for=\"cdescription\">Description (required) </label> <textarea id=\"elm1\" class=\"required\" name=\"description\" maxlength=\"1000\" rows=\"\" cols=\"\">$Description</textarea>"; <label>Want <input type=\"radio\" name=\"adtype\" value=\"want\" onclick=\"reload(this.form)\" /></label> ?> I integrate TinyMCE with a web application. After plugging in TinyMCE, a textarea shows up on a place where no textarea is defined. So far, this problem happens on a web page with multiple textareas. It seems to be caused by either <fieldset> tag or a <TEXTAREA .. readonly>. A non-defined textarea shows on the top of these elements. Does anyone else run into the same problem? Thanks. HI I'm new to tinymce. I'm using tinymce with jquery validate with remote Methods. (Remote Methods: http://docs.jquery.com/Plugins/Valid...Methods/remote) I'm using jquery validate to check if email address already has been enter into the database, once it check the email hasn't been entered. It then enter the email with the tinymce textarea. Right now the email address gets enter but tinymce textarea is undefined. I understand I have to uses the var content = tinyMCE.get (editor_id);, but its still enter as undefined, here is my code below: Code: <html> <head> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.validate.js"></script> <script type="text/javascript" src="js/tiny_mce.js"></script> <script type="text/javascript"> tinyMCE.init({ // Location of TinyMCE script // General options mode : "textareas", elements : "editor_id", theme : "advanced", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, content_css : "css/content.css", }); <script type="text/javascript"> $(document).ready(function(){ var validator = $("#myform").validate({ rules: { email: { required: true, minlength: 5, remote: { url: "test.php", type: "post", data: { dataType: 'json', email: function() { return $("#email").val(); }, content: function() { return $("content").val(); } }, }, } }, messages: { sub_name: { required: "Please enter a email address", minlength: "Your email addressmust be at least 5 characters long", remote: jQuery.format("Sorry but '{0}' has already been added. Please try again.") } }); }); </script> </head> <body> <form id="myform" action="" method="post"> <input type="text" name="email" id="email" size="15"/> <textarea id="editor_id" name="editor_id" rows="15" cols="80" ></textarea> <input type="submit" value="Submit"/> </form> Where do I added? Code: var content = tinyMCE.get('editor_id'); content = escape(content.getContent()); content = content.replace("+", "%2B"); content = content.replace("/", "%2F"); thanks Hi all, After over a month of pounding my head against the wall (and getting ZERO help from the TinyMCE "support" forum), I have finally come up with a simple JS function (for the TinyMCE editor) that will wrap a selection with any open and any close tag one wishes, and keeps the selected text selected for further wrapping if desired. Here's the code (commented heavily): Code: /* -------- FOR TINYMCE ONLY -------- * wrap selection with BBCode or other tags * (c) 2010 r.a.krupski <krupski@roadrunner.com> * free software - use, modify, distribute freely ** -------- FOR TINYMCE ONLY --------*/ function tinyWrap(open_tag, close_tag) { var ed = (tinymce.activeEditor || opener.tinymce.activeEditor); /* get editor instance */ var selection = ed.selection.getContent(); /* get user selection, if any */ var temp_name = new Date().getTime().toString(36).toLowerCase(); /* generate a unique string */ var span_open = '<span id="' + temp_name + '">'; /* generate '<span id="unique">' */ var span_close = '</span>'; /* generate closing '</span>' */ selection = selection.replace(/<p>/g,'').replace(/<\/p>/g,'<br />'); /* convert <p></p> to <br /> */ if (selection.substr(selection.length-6) === '<br />') { selection = selection.substr(0, selection.length-6); /* strip last <br /> if present */ } /* create complete selection replacement: '<span id="unique">OPEN_TAGselectionCLOSE_TAG</span>' */ var content = open_tag + span_open + selection + span_close + close_tag; ed.execCommand('mceReplaceContent', false, content); /* replace selection with new */ var span_elem = ed.dom.get(temp_name); /* get the element of the temp span */ ed.selection.select(span_elem); /* select (highlight) the selection span */ ed.dom.remove(temp_name, true); /* remove the span, leave it's highlighted text behind(true) */ ed.focus(); /* insure editor has focus */ return; /* taa-daa! all done! */ } Hope this helps someone - I've got a few more gray hairs because of TinyMCE... hopefully this will spare others my agony...... -- Roger Hi Guys, im using chrome and ff and it worked fine till i tested on ie7 and the form just wont send on ie7. it gives me a validation error msg "SOME VALUES ARE NOT ACCEPTABLE" when i try to submit. ive tried so many things and i cant figure out why ie7 wont send upon submit like ff does, code seems to be fine, pls see validation coding line 7 - 32 , any jsGURU advice will be much appreciated! Code: <?php defined('_JEXEC') or die('Restricted access'); ?> <?php JHTML::_('behavior.formvalidation'); ?> <script language="javascript" type="text/javascript"> function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'cancel') { submitform( pressbutton ); return; } // do field validation if (document.getElementById('jformfirstname').value == ""){ alert( "<?php echo JText::_( 'Firstname is missing.', true ); ?>" ); } else if (document.getElementById('jformsurname').value == ""){ alert( "<?php echo JText::_( 'Surname is missing.', true ); ?>" ); } else if (document.getElementById('jformemail').value == ""){ alert( "<?php echo JText::_( 'Email is missing.', true ); ?>" ); } else if (document.getElementById('jformphone1').value == ""){ alert( "<?php echo JText::_( 'Phone1 is missing.', true ); ?>" ); } else { if (document.formvalidator.isValid(form)) { submitform( pressbutton ); } else { alert("<?php echo JText::_( 'SOME VALUES ARE NOT ACCEPTABLE.', true ); ?>"); } } } </script> <?php if ($this->courseid){ ?> <?php if ( $this->params->def( 'show_page_title', 1 ) ) : ?> <div class="componentheading<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo $this->courseDetails->title; ?> </div> <?php endif; ?> <h3>Course Details</h3> <table cellSpacing=0 cellPadding=5 width="90%" border=0> <tr> <td width="20%"><?php echo JText::_( 'Course Title' ); ?>:</td> <td width="30%"><?php echo $this->courseDetails->title;?></td> <td width="20%"><?php echo JText::_( 'Code' ); ?>:</td> <td width="30%"><?php echo $this->courseDetails->code;?></td> </tr> <tr> <td><?php echo JText::_( 'Price' ); ?>:</td> <td><?php echo (number_format($this->courseDetails->price,2));?></td> <td><?php echo JText::_( 'No. of Days' ); ?>:</td> <td><?php echo $this->courseDetails->capacity;?></td> </tr> <tr> <?php if ($_GET['hide'] != 1 ) { ?> <td><?php echo JText::_( 'Location' ); ?>:</td> <td><?php echo $this->courseDetails->course_location;?></td> <?php } else { echo "<td> </td>"; echo "<td> </td>"; } ?> </tr> <tr> <?php if ($_GET['hide'] != 1 ) { ?> <td><?php echo JText::_( 'Start Date' ); ?>:</td> <td><?php echo Date('d-M-y', strtotime($this->courseDetails->start_date));?></td> <?php } else { echo "<td> </td>"; echo "<td> </td>"; } ?> </tr> </table> <?php } ?> <?php if ( $this->params->def( 'show_course_sessions', 1 ) && ($this->courseid) ) : ?> <h3>Sessions</h3> <table cellSpacing=0 cellPadding=5 width="90%" border=0> <tr> <td width="20%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Day'); ?> </td> <td width="20%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Start Time'); ?> </td> <td width="20%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Finish Time'); ?> </td> <td width="10%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Duration'); ?> </td> <td width="30%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Location'); ?> </td> </tr> <?php $k = 0; $n=count( $this->course_sessions ); if ($n > 0){ for ($i=0, $n; $i < $n; $i++) { $row = &$this->course_sessions[$i]; ?> <tr> <td align="center"> <?php echo $row->session_day;?> </td> <td align="center"> <?php echo date('H:i', strtotime($row->start_time));?> </td> <td align="center"> <?php echo date('H:i', strtotime($row->finish_time));?> </td> <td align="center"> <?php echo $row->duration;?> </td> <td align="center"> <?php echo $row->session_location;?> </td> </tr> <?php $k = 1 - $k; } } else { ?> <tr> <td colspan="5"><? echo JText::_( 'There are no sessions for this course' );?></td></tr><?php } ?> </table> <?php endif; ?> <form action="<?php echo $this->action ?>" method="post" name="adminForm" id="adminForm" class="form-validate"> <?php if ( $this->params->def( 'show_page_title', 1 ) ) : ?> <div class="componentheading<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo $this->escape($this->params->get('page_title')); ?> </div> <?php endif; ?> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr> <td width="15%"> <label for="jformcourseid"> <?php echo JText::_( 'Course' ); ?>: </label> </td> <td> <?php echo $this->lists['courseid'];?>* </td> </tr> <?php if ($_GET['hide'] == 1 ) { ?> <tr> <td valign="top"> <label for="jformcity"> <?php echo JText::_( 'I want to attend this course here' ); ?>: </label> </td> <td width="80%"> <select class="required" type="text" id="jformcountry" name="jform[country]" value="<?php echo $this->escape($this->booking->country);?>" />* <option>Choose your Location</option> <option>Melbourne</option> <option>Sydney</option> <option>Auckland</option> </select> </td> </tr> <?php } ?> <tr> <td valign="top"> <label for="jformfirstname"> <?php echo JText::_( 'Firstname' ); ?>: </label> </td> <td width="80%"> <input class="required" type="text" id="jformfirstname" name="jform[firstname]" size="50" maxlength="250" value="<?php echo $this->escape($this->booking->firstname);?>" />* </td> </tr> <tr> <td valign="top"> <label for="jformsurname"> <?php echo JText::_( 'Surname' ); ?>: </label> </td> <td valign="top"> <input class="required" type="text" id="jformsurname" name="jform[surname]" size="50" maxlength="250" value="<?php echo $this->escape($this->booking->surname);?>" />* </td> </tr> <?php if($this->userid > 0) { ?> <tr> <td valign="top"> <label for="jformusername"> <?php echo JText::_( 'Username' ); ?>: </label> </td> <td width="80%"> <input class="required" type="text" id="jformusername" name="jform[username]" size="50" maxlength="100" value="<?php echo $this->escape($this->username);?>" READONLY/>* </td> </tr> <?php } ?> <tr> <td valign="top"> <label for="jformdepartment"> <?php echo JText::_( 'Company' ); ?>: </label> </td> <td width="80%"> <input class="inputbox" type="text" id="jformdepartment" name="jform[department]" size="50" maxlength="30" value="<?php echo $this->escape($this->booking->department);?>" /> </td> </tr> <tr> <td valign="top"> <label for="jformemail"> <?php echo JText::_( 'Email' ); ?>: </label> </td> <td width="80%"> <input class="validate-email" type="text" id="jformemail" name="jform[email]" size="50" maxlength="100" value="<?php echo $this->escape($this->email);?>"/>* </td> </tr> <tr> <td valign="top"> <label for="jformphone1"> <?php echo JText::_( 'Phone Number' ); ?>: </label> </td> <td width="80%"> <input class="required" type="text" id="jformphone1" name="jform[phone1]" size="50" maxlength="20" value="<?php echo $this->escape($this->booking->phone1);?>" />* </td> </tr> <tr> <td valign="top"> <label for="jformcity"> <?php echo JText::_( 'Locations' ); ?>: </label> </td> <td width="80%"> <select type="text" id="jformcity" name="jform[city]" value="<?php echo $this->escape($this->booking->city);?>" /> <option>Choose your Location</option> <option>Melbourne</option> <option>Sydney</option> <option>Auckland</option> </select> </td> </tr> <tr> <td valign="top"> <label for="jforminstitution"> <?php echo JText::_( 'Referral Source' ); ?>: </label> </td> <td width="80%"> <select type="text" id="jforminstitution" name="jform[institution]" value="<?php echo $this->escape($this->booking->institution);?>" /> <option>How did you find out about us?</option> <option>Search Engine</option> <option>Friends</option> <option>Others</option> </select> </td> </tr> <tr> <td valign="top"> <label for="jformdescription"> <?php echo JText::_( 'Comments' ); ?>: </label> </td> <td> <textarea class="inputbox" cols="47" rows="6" id="jformdescription" name="jform[description]"><?php echo $this->escape( $this->booking->description);?></textarea> </td> </tr> </table> <div> <button type="button" class="button validate" onclick="submitbutton('save')"> <?php echo JText::_('Save') ?> </button> <button type="button" onclick="submitbutton('cancel')"> <?php echo JText::_('Cancel') ?> </button> </div> <input type="hidden" name="jform[id]" value="<?php echo $this->booking->id; ?>" /> <input type="hidden" name="jform[ordering]" value="<?php echo $this->booking->ordering; ?>" /> <input type="hidden" name="jform[approved]" value="<?php echo $this->booking->approved; ?>" /> <input type="hidden" name="jform[userid]" value="<?php echo $this->userid; ?>" /> <input type="hidden" name="option" value="com_courseman" /> <input type="hidden" name="controller" value="booking" /> <input type="hidden" name="task" value="" /> <?php echo JHTML::_( 'form.token' ); ?> </form> </br> Fields marked with an asterisk (*) are required. </br> </br> Any idea why my code will not add a row? Code: function addRow() { var tbl = document.getElementById('thetable'); var lastRow = tbl.rows.length; var row = tbl.insertRow(lastRow); var cell1 = row.insertCell(0); cell1.setAttribute('align','center') var input = document.createElement('input'); input.name = 'date' + lastRow; input.id = 'date' + lastRow; cell1.appendChild(input); var cell2 = row.insertCell(1); cell2.setAttribute('align','center') input = document.createElement('input'); input.name = 'goals' + lastRow; input.id = 'goals' + lastRow; cell2.appendChild(input); var cell3 = row.insertCell(1); cell3.setAttribute('align','center') input = document.createElement('input'); input.name = 'venue' + lastRow; input.id = 'venue' + lastRow; cell3.appendChild(input); var cell4 = row.insertCell(1); cell4.setAttribute('align','center'); input = document.createElement('select'); input.name = 'terrain' + lastRow; input.id = 'terrain' + lastRow; var s = "Road/Track/Multi Terrain/Cross Country".split("/"); for(var i=0;i<s.length;i++) { var o = document.createElement("option"); o.value = s[i]; o.text = s[i]; input.add(o); } cell4.appendChild(input); } window.onload = function() { var cell5 = document.getElementById("cell5"); cell5.setAttribute('align','center'); input.name = 'distance' + lastRow; input.id = 'distance' + lastRow; var input = document.createElement("select"); var s = "3000m/5000m/10,000m/5 Miles/10 Miles/20 Miles/Half Marathon/Marathon /Other".split("/"); for(var i=0;i<s.length;i++) { var o = document.createElement("option"); input.options[i] = new Option(s[i], s[i]); } cell5.appendChild(input); } } function delRow() { var tbl = document.getElementById('thetable'); var lastRow = tbl.rows.length; if (lastRow > 2) tbl.deleteRow(lastRow - 1); } </script> I'm trying to figure out the proper way to correctly get each full-formation of encoded html (of Unicode), so that I could assign each HTML encoding with its each Unicode characters HTML Encoded Unicode: &#2344;&#2351;&#2366; &#2344;&#2375;&#2346;&#2366;&#2354; I want to retrieve each encoded HTML and assign them into array like this Code: var my_array = new Array(); my_array [0] = "2344"; my_array [1] = "2351"; my_array [2] = "2366"; my_array [3] = "2344"; my_array [4] = "2375"; my_array [5] = "2346"; my_array [6] = "2366"; my_array [7] = "2354"; Thanks in Advance for helps Need to know how to define hex characters for the following; var x = hex value var y new Array(hex value, hex value, etc) document.write(hex value) This will work in firefox but not IE. Any alternative I am new to coding and not sure how to do this. Code: <div id="leftnav"> <ul> <li><a href="home.html"><img src="home1.gif" onmouseover="document.homeb.src='home2.gif';" onmouseout="document.homeb.src='home1.gif';" id= "homeb" alt="home1"></a></li> <li><a href="striping.html"><img src="striping.gif" alt="striping" id="striping" onmouseover= "document.striping.src='striping2.gif';" onmouseout="document.striping.src='striping.gif';"> </a></li> <li><a href="design.html"><img src="design.gif" alt="design" id="design" onmouseover= "document.design.src='design2.gif';" onmouseout= "document.design.src='design.gif';"></a></li> <li><a href="lettering.html"><img src= "lettering.gif" alt="lettering" id="lettering" onmouseover= "document.lettering.src='lettering2.gif';" onmouseout= "document.lettering.src='lettering.gif';"></a></li> <li><a href="contact.html"><img src="contact.gif" alt="contact" id="contact" onmouseover= "document.contact.src='contact2.gif';" onmouseout= "document.contact.src='contact.gif';"></a></li> </ul> </div> hey all, what it says in the title, this block of code wont work and i dont know why. the first prompt box appears but not the "can vote, but can't drink" reply. can anyone offer any ideas? <!DOCTYPE html> <html> <head> <title>legal age</title> <script type="text/javascript"> var your_age = prompt("how old are you?"); if ((age > 18) && (age < 21)) { document.writeln("can vote, but can't drink."); } </script> </body> </html> kind regards, Redd . Problem solved, thanks for looking.
My function the_magnitude() takes in values from 4 different asp:textboxes. The textboxes "easting" and "northing" contain numbers that don't change, but the textboxes "east" and "north" contain numbers inputed by the user, and the function returns "error" as a value to be put into another textbox that we'll call "error box". So what it's suppose to do is when I update the information in either "east" or"north" it will update, on change, the number in the "error box". It kinda works. My problem is that if the number is a value that changes the style to red, #ff0000, in the function it wont update the "error box" and it just leaves a red zero that is a default number in the box. The only way I can get the number to change is if I end up with a number less than 200, which would make the text green. I'm pretty sure it's a problem with my javascript. here is my function Code: <script type="text/javascript"> function the_magnitude(easting, east, northing, north, error) { var a = easting.value; var b = east.value; var c = northing.value; var d = north.value; var total = Math.sqrt(((a - b) * (a - b)) + ((c - d) * (c - d))); if (total > 200) { document.getElementById('TextBox155').style.color = "#ff0000"; document.getElementById('TextBox155').style.fontWeight = "bold"; } else { document.getElementById('TextBox155').style.color = "#008000"; document.getElementById('TextBox155').style.fontWeight = "bold"; error.value = roundNumber(total); } } </script> and here are the two buttons that I input numbers into for east and north Code: <html> <body> <asp:TextBox ID="TextBox153" runat="server" Height="0.25in" Style="font-family: Arial, Helvetica, sans-serif; font-size: small; text-align: center" Width="0.75in" onchange="the_magnitude(document.getElementById('TextBox153'), document.getElementById('TextBox212'), document.getElementById('TextBox154'), document.getElementById('TextBox213'), document.getElementById('TextBox155'))" ></asp:TextBox> </body> </html> Code: <html> <body> <asp:TextBox ID="TextBox153" runat="server" Height="0.25in" Style="font-family: Arial, Helvetica, sans-serif; font-size: small; text-align: center" Width="0.75in" onchange="the_magnitude(document.getElementById('TextBox153'), document.getElementById('TextBox212'), document.getElementById('TextBox154'), document.getElementById('TextBox213'), document.getElementById('TextBox155'))" ></asp:TextBox> </body> </html> and here is the textbox that I want the return of the function to go into. Code: <html> <body> <asp:TextBox ID="TextBox155" runat="server" Height="0.25in" Style="font-family: Arial, Helvetica, sans-serif; font-size: small; text-align: center" Width="0.5in">0</asp:TextBox> </body> </html> hi I created a forloop and that runs fine, but it wont run any code after the loop finishes. I've tryed playing around with it but nothing I do will make it display the alert. Heres the problem code: Code: function price() { var price=0; for(var i=1; i<=15; i++) { if(document.form.partPrice[i].value == "price" == false) { price+=Number(document.form.partPrice[i].value); alert("test"); } } //wont run any code after here alert(price); } I'm not sure whats wrong, its probably something small that im overlooking but I just cant find whats wrong thanks in advance! Hey I have a JS value but it won't put the value in the brackets when i try to get the element by ID instead it is looking for the id named the same as the variable name. Here is what i got to explain better: Code: function fill_div(v) { document.getElementById(v).innerHTML="<img src='untitle.png' style='width:100%;height:100%;'/>"; } var x = 0; var y = 3; var area = 1; window.onload = fill_div(area+':'+x+':'+y); It ends up looking for id v instead of id 1:0:3. Any idea how i correct this ? So, I have this javasript code in HEAD <script type="text/javascript"> <!-- function validateThis(registerForm) { if (registerForm.firstname.value == 'Name') { alert("Oops"); return false; } else { return true; } } //--> </script> with this form in BODY <form action="register.php" method="post" name="registerForm" onSubmit="return validateThis(this)"> <input type="text" value="Name" onclick="if(this.value=='Name'){this.value=''}" onblur="if(this.value==''){this.value='Name'}" name="firstname"> </form> and I want to put a text with Greek characters instead of value "Name". I tried it and the "function validateThis" didn't work. The form just passes it and returns true. I tried also hexadecimal code,HTML entities and numeric HTML entities and didn't work either. What I should I do? Thank you in advance! First of all thanks for all the help you are providing. I am looking to alert a user if they type in an character that I am going to not allow for their input box Code: function IsExc (str){ var AllChr = "~ # $ % ^ { } [ ] ' ,"; var AC= AllChr.split(" "); var SC = 0; for (SC=0; SC <= AC.length; SC++){ var ACS = AC[SC]; if (str.search(ACS) >0 ) alert ('Cannot use the characters' + AllChr ) } } For reasons I don't understand the code will not work I have a textbox ( I am using asp.net ). I want to use that textarea as rich text box. The text in textarea is submitted to database and then displayed. So, I can use <b><u> tags, but I want to use smileys too. I need a simple code for it. My logic is simple..., Whatever text is written inside the textarea is first read and when a group of specific character like Code: " :) ;) x-(" are found, that characters should be colored to red . So, a Code: :) will appear as Code: :) . This logic is simple but I am new to javascript programming, it cant implement it. Can a provide a javascript for this, or if you have better but simple code plz let me know. I have a simple function like this: Code: function chars_remaining() { var remaining = 200 - document.getElementById("text_box").value.length; document.getElementById("number").innerHTML = 'Characters Remaining: ' + remaining; } And I call this onkeyup on the textarea. 200 chars max and what happens is when they type a character, it will still stay at 200 until they press another key. So when it will be 199, it should actually be 198. Onkeyup, onkeydown, onkeypress will all do the same thing. How can I make it so that as soon as they press a key it changes right away? Also I insert this into my database with mysql_real_escape_string, which is limited at 200 chars. When they keep typing and get to 0 remaining characters if they had any quotes, backslashes, etc. they will get added and thus some of their text will be cut off. I.e. lets say the text ended with "good luck". If they had 3 quotes in their text it might end up being "good l" instead because 3 backslashes had to be used to escape. So would the best thing to do be to count a quote, backslash, etc. as two characters instead of one. How would I do that in JS? How can to obtain length of string variable, for example if I have: var msg = 'hello world!'; Does it exist a method to count string characters? |