July 17th, 2010
For those who scour the net for a simple solution for a problem called “Make my YouTube embed code pass w3c HTML validation“, your in the PERFECT place, because what you’re about to read is not only simple, but the perfect solution!
Very confident me will now show you how its done
…
The usual Youtube embed code(do not pass w3c HTML validation)
NOTE: where ($vid) is your Youtube video ID
<object width="430" height="347">
<param name="movie" value="http://www.youtube.com/v/($vid)&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/($vid)&hl=en_US&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="430" height="347"></embed>
</object>
Ok you see, when using this code to display video, it will never pass validation but instead will render validation error such as “there is no attribute allowfullscreen”, “width” among others.
But with the code below, you can perfectly validate your Youtube pages
see below and test it yourself.
NOTE: ($vid) is = to your Youtube video ID, for example http://www.youtube.com/v/RHzC7YOxkVY&hl=en_US&fs=1 the emphasized letters is your Youtube ID, So now presenting the code…
<object type="application/x-shockwave-flash" width="430" height="347" data="http://www.youtube.com/v/($vid)">
<param name="movie" value="http://www.youtube.com/v/($vid)" /></object>
Oh my, yes its much shorter, and its better!!!
Tags: embed to pass html validation, html validation, youtube code passed html validation, youtube code to pass w3c html validation
Posted in CSS, General, HTML, What I have learned today | 1 Comment »
July 1st, 2010
Javascript concatenates instead of adding two form values?
Ok, lets test this
SEE DEMO
<form id="form2" name="form2" method="post" action="#" onsubmit="document.getElementById('total2').value=parseInt(document.getElementById('field12').value)+parseInt(document.getElementById('field22').value); return false;">
<p>
<input type="text" name="field12" id="field12" />
</p>
<p>
<input type="text" name="field22" id="field22" />
</p>
<p>
<input type="submit" name="button" id="button" value="Add" />
=
<input name="total2" type="text" id="total2" size="10" />
</p>
</form>
True enough treat form values as string, so concatenates.
So, what should we do to make Javascript add those form values?
We can use Javascript function called parseInt().
The parseInt() function parses a string and returns an integer.
Ex: form.field2.value+form.field2.value (this will only concatenate)
SEE DEMO
<form id="form2" name="form2" method="post" action="#" onsubmit="document.getElementById('total2').value=parseInt(document.getElementById('field12').value)+parseInt(document.getElementById('field22').value); return false;">
<p>
<input type="text" name="field12" id="field12" />
</p>
<p>
<input type="text" name="field22" id="field22" />
</p>
<p>
<input type="submit" name="button" id="button" value="Add" />
=
<input name="total2" type="text" id="total2" size="10" />
</p>
</form>
Thats it! that should add two form values perfectly
feel free to post any question and or comments thanks.
Tags: JavaScript, javascript concaenates instead of adding two values, javascript function, parseInt();
Posted in HTML, JavaScript, What I have learned today | 1 Comment »
June 22nd, 2010
Editing Magento’s default currency symbol is relatively easy and can be done via admin.
But what if you wanted to display “USD” instead of “$”?
This too is easy enough for most of us-if you know where to look at!
Ok ok, to edit or customize default currency symbol look into;
MAGENTO_ROOT/lib/Zend/Locale/Data/
Look for you locale, in most cases en.xml (which is english), download and open it in your favorite editor, replace below code
<currency type="USD">
<displayName>US Dollar</displayName>
<displayName count="one">US dollar</displayName>
<displayName count="other">US dollars</displayName>
<symbol>$</symbol>
</currency>
With this code:
<currency type="USD">
<displayName>US Dollar</displayName>
<displayName count="one">US dollar</displayName>
<displayName count="other">US dollars</displayName>
<symbol>USD</symbol>
</currency>
I think you already noticed what we omit and replace on the code
, easy enough, saved it and upload it to your server.
To make your life even more easier here’s a tip: you can find this line of code around line 3800 in en.xml
GOGOGO
Tags: edit magento currency symbol, magento currency symbol
Posted in Found, What I have learned today | 3 Comments »
June 22nd, 2010
hello everyone, I don’t think this post will do much, but certainly will save someone’s time finding the Magento’s Customer Login Template (login.phtml).
I’d like to share this because I spent hours trying to find this particular file and after long hours I finally found and edit it to my needs
Here the location:
MAGENTO_ROOT/app/design/frontend/default/default/template/customer/form/
Look for the file login.phtml and that should be the one you looking for.
Magento file structure can be deeper for plenty for us making it harder to manipulate. (at east as far im concern hehehe
go now and edit your login )
Tags: amgento login, find magento customer login file, magento, magento customer login
Posted in Found, What I have learned today | No Comments »
May 31st, 2010
Sometimes we wanted to validate user inputs, and more often than not we want to restrict then to only accept letters, numbers and spaces for a specific form field.
Today Ill show you how to do this via Javascript.
The below codes will demonstrate this for your quick understanding:
<form id="form1" name="form1" onsubmit="if(/[^A-Za-z\d ]/.test(this.textfield.value)){alert('String should contain letters and numbers only');}else{alert('String passed');}" method="post" action="">
<input type="text" name="textfield" id="textfield" value="Input text here." onclick="this.value=''" />
<input type="submit" name="button" id="button" value="Submit" />
</form>
On submit event Javascript will test value of the textfield using “/[^A-Za-z\d ]/“, if any character is found other than letter, number and space it will return TRUE and alert us that it contains illegal character(s) (letter, number and space).
Please see demo
Easy huh, try it yourself.
Tags: javascript validation, validate alpha numeric only, validate form to accept only alphanumeric, validate form via javascript to accept only letter and numbers
Posted in JavaScript, What I have learned today | 8 Comments »