Results 1 to 10 of 10

Thread: Encoding problem with alert popup (please help) !

  1. #1
    Join Date
    Nov 2006
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Encoding problem with alert popup (please help) !

    I am using turkish character my site.(ISO 8859-9) The forms characters appears correctly.But alert popups character set not appears correctly.

    It is a english form and I transtlate words like this to turkish;

    Code:
    DEFINE( "ADSMANAGER_FORM_AD_TEXT", "Açıklama");
    DEFINE( "ADSMANAGER_FORM_KINDOF", "Gönderi Şekli");

    and the codes...
    Code:
    	<script type="text/javascript"><!--//--><![CDATA[//><!--
    		function submitbutton(mfrm) {
    			var me = mfrm.elements;
    			var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");
    			var r_num = new RegExp("[^0-9\.,]", "i");
    			var r_email = new RegExp("^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,3}$" ,"i");
    
    			var errorMSG = '';
    			var iserror=0;
    			
    			<?php 
    			if (function_exists("loadEditFormCheck")){
    				loadEditFormCheck($row);
    			}
    			?>
    			
    			if (mfrm.username && (r.exec(mfrm.username.value) || mfrm.username.value.length < 3)) {
    				errorMSG += mfrm.username.getAttribute('mosLabel').replace('&nbsp;',' ') + ' : <?php echo addslashes(html_entity_decode(sprintf( ADSMANAGER_VALID_AZ09, ADSMANAGER_PROMPT_UNAME, 4 ),ENT_QUOTES)); ?>\n';
    				mfrm.username.style.background = "red";
    				iserror=1;
    			} 
    			if (mfrm.password && r.exec(mfrm.password.value)) {
    				errorMSG += mfrm.password.getAttribute('mosLabel').replace('&nbsp;',' ') + ' : <?php echo addslashes(html_entity_decode(sprintf( ADSMANAGER_VALID_AZ09, ADSMANAGER_REGISTER_PASS, 6 ),ENT_QUOTES)); ?>\n';
    				mfrm.password.style.background = "red";
    				iserror=1;
    			}
    			
    			if (mfrm.email && !r_email.exec(mfrm.email.value) && mfrm.email.getAttribute('mosReq')) {
    				errorMSG += mfrm.email.getAttribute('mosLabel').replace('&nbsp;',' ') + ' : <?php echo html_entity_decode(addslashes(ADSMANAGER_REGWARN_MAIL),ENT_QUOTES); ?>\n';
    				mfrm.email.style.background = "red";
    				iserror=1;
    			}
    						
    			// loop through all input elements in form
    			for (var i=0; i < me.length; i++) {
    			
    				if ((me[i].getAttribute('test') == 'number' ) && (r_num.exec(me[i].value))) {
    					errorMSG += me[i].getAttribute('mosLabel').replace('&nbsp;',' ') + ' : <?php echo html_entity_decode(addslashes(ADSMANAGER_REGWARN_NUMBER),ENT_QUOTES); ?>\n';
    					iserror=1;
    				}
    				
    				// check if element is mandatory; here mosReq="1"
    				if (me[i].getAttribute('mosReq') == 1) {
    					if (me[i].type == 'radio' || me[i].type == 'checkbox') {
    						var rOptions = me[me[i].getAttribute('name')];
    						var rChecked = 0;
    						if(rOptions.length > 1) {
    							for (var r=0; r < rOptions.length; r++) {
    								if (rOptions[r].checked) {
    									rChecked=1;
    								}
    							}
    						} else {
    							if (me[i].checked) {
    								rChecked=1;
    							}
    						}
    						if(rChecked==0) {
    							// add up all error messages
    							errorMSG += me[i].getAttribute('mosLabel').replace('&nbsp;',' ') + ' : <?php echo html_entity_decode(addslashes(ADSMANAGER_REGWARN_ERROR),ENT_QUOTES); ?>\n';
    							// notify user by changing background color, in this case to red
    							me[i].style.background = "red";
    							iserror=1;
    						} 
    					}
    					if (me[i].value == '') {
    						// add up all error messages
    						errorMSG += me[i].getAttribute('mosLabel').replace('&nbsp;',' ') + ' : <?php echo html_entity_decode(addslashes(ADSMANAGER_REGWARN_ERROR),ENT_QUOTES); ?>\n';
    						// notify user by changing background color, in this case to red
    						me[i].style.background = "red";
    						iserror=1;
    					} 
    				}
    			}
    			
    			if(iserror==1) {
    				alert(errorMSG);
    				return false;
    			} else {
    				return true;
    			}
    		}
    		//--><!]]></script>
    and problem picture

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Alerts will not use HTML named or numbered entities like:

    Code:
    &copy;
    or:

    Code:
    &#350;
    You need to find the hex value of the character and use it like so (for the copyright symbol which is hex a9):

    Code:
    \xa9
    Example in an alert:

    Code:
    alert('\xa9');
    You can also use four digit Unicode character codes, once again for copyright:

    Code:
    alert('\u00a9');
    or for that other symbol (Ş):

    Code:
    alert('\u015e');
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2006
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry but I don't understand
    What am I write in language file
    for example here
    DEFINE( "ADSMANAGER_FORM_AD_TEXT", "A&ccedil;ıklama");

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You are going to need some Unicode character charts, there are several online, use Google to find them. For that particular character, it would be:

    Code:
    DEFINE( "ADSMANAGER_FORM_AD_TEXT", "A\u00e7ıklama");
    If this is used in HTML as well as in alert though, there could be problems. You may have to separate the text used in alerts from that used in the markup if your code isn't already setup that way.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Nov 2006
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    not solved problem



    language and php files in attachment.Please help.
    Sorry my bad english

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This works here:

    Code:
    <script type="text/javascript">
    alert('A\u00e7iklama');
    </script>
    I'll have to have a look at your code in more detail, as it apparently is messing this up. You might be able to just double the escape though:

    Code:
    DEFINE( "ADSMANAGER_FORM_AD_TEXT", "A\\u00e7ıklama");
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    DEFINE() is not a function. I need to see your page:

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Nov 2006
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ****-**
    Last edited by winpeace; 07-18-2008 at 06:05 PM.

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Sorry, I didn't see your attached files. That's PHP (not something I'm real good at), not javascript.

    What I told you about the alert in javascript is accurate. A javascript alert will not accept HTML entities. You must use hex or Unicode character escapes (as I've already explained) for any unusual characters in the alert.

    If you need help arranging your server side code go to the PHP forum:

    http://www.dynamicdrive.com/forums/f...splay.php?f=11
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #10
    Join Date
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default That's very late but maybe useful for others having the same problem

    Quote Originally Posted by winpeace View Post
    I am using turkish character my site.(ISO 8859-9)
    and problem picture
    I solve this problem with just opening script file in notepad and save again in unicode format, it works for me

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •