JavaScript - Greek Characters And Javascript
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! Similar Tutorialshi all, am doing a check on my fields, so that they only contain certain characters and numbers. i have this. var validEntry = /^[a-zA-Z0-9@$&"]+/; but this also captures a space in between words as an error. can somebody please tell me on how to avoid this. thanks. Is there an inbuilt function in javascript to convert web characters like
Code: & back to '&' for use in a search text field? This is driving me nuts I need to replace all instances of "zz" with 'Z'. I can easily replace other strings such as a = a.replace(/mickeymouse/, "Z"); but a = a.replace(/zz/, "Z"); doesn't work. Must be a double characer thing? Hi everyone. I do all of my writing and editing in notepad but can't figure out how to use characters from different charsets in the same script-block. For example if I wanted to write Code: if ( CharInput=="ش" ) { N = 1;} if ( CharInput=="厜" ) { N = 2;} I've found the unicode the number for ش is 0634 and 厜 is 539C. But I don't know how to use them. My question is how do I modify the above piece of code so it works in something like notepad? I can't cut and paste them in because in plain text files like that of notepad the formating is lost and I'm pretty sure html wouldn't allow that anyway. Thanks for reading 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) 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 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? I am using the below javascript to verify a text input box but I would also like to require atleast 3 characters being entered before allowing the user to search. How do I accomplish that? Thanks in advance! Code: <script language="JavaScript"> <!-- /*********************************************** * Required field(s) validation v1.10- By NavSurf * Visit Nav Surf at http://navsurf.com * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ function formCheck(formobj){ // Enter name of mandatory fields var fieldRequired = Array("words"); // Enter field description to appear in the dialog box var fieldDescription = Array("Company Name"); // dialog message var alertMsg = "Please complete the following fields:\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired[i]]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription[i] + "\n"; } } } } if (alertMsg.length == l_Msg){ return true; }else{ alert(alertMsg); return false; } } // --> </script> 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 Code: <script type="text/javascript" src="external.php?type=js"></script> <script language="" type="text/javascript"> <!-- for (x = 0; x < 10; x++) { document.writeln("<a href=\"showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a>, "); } //--> </script> My code will display 10 posts, however at the very end it will display an extra ", " which bugs me. How can I strip those last two characters. Can some one help me, I want to replace the characters from a string and I have tried with this script: Code: var v5=form.description.value.replace(/#/, "%23"); But it only changes the first character from the string. Turning #### into %23### but I want them all transformed. Hi, So I've got an array called questions_raw Code: questions raw = [ ["<Q1> Question", "choice1","choice2", "choice3"], ["<Q2> Question", "choice1","choice2", "choice3"], ... ] And I want to list all of the questions, but not the choices/answers. So far, I've managed to list just the questions, but because another function randomly sorts them, I need to sort them back into numerical order for a separate function (displaying the questions) I use characters (>,^) at the front to separate them into different answer types (just to explain the code) I try this to cut each string down so that they can be sorted numerically/alphebetically - Code: function linearlist() { var list = []; var tempStr = ""; for (var l = 0; l < 145; l++) { tempStr = questions_raw[l][0]; list[l] = tempStr; } if (list.charAt(0)== " " ) list = list.substring(3) ; if (list.charAt(0)== ">" ) list = list.substring(3) ; if (list.charAt(0)== "^" ) list = list.substring(3) ; var sorted = list.sort(); document.Qtext2form.Qtext2.value = sorted.join("\n"); } But it doesn't like it - because "it has no method charAt" Any idea what i'm missing? Is it just that you have to put the [l] in every time you call a variable? Cheers My credit card processing service will only accept English characters. I need to detect entries in the form that are using non English characters. Is there a way in Javascript to create a function to force a string to UTF-8? My idea is to do something like function forceUTF8(X){ Y = ???? X; return Y; } if ( stringA != forceUTF8(stringA) alert ("You must use English 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 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? Here is the code i am trying. Code: var str="اسدف"; patt=/[\u0600-\u06FF\u0750-\u077F]/; result=patt.test(str); document.write("<br />Returned value: " + result); </script> This should return true, as the string in the str variable is indeed Arabic character. But it returns false. Need some help here on this.. Thanks in Advance Hi, I have the following code: Code: var str = "/dev/filler/test0/"; var patt = new RegExp("/ test0 /$"); var result = patt.exec(str); document.write(result); which returns: /test0/ in the var patt line I would like to replace the hardcoded test0 string with an expression that matches any characters between the two forward slashes. I have tried with little success. |