Replace character onBlur

<script type="text/javascript">
function replaceCharacters() {
var origString = document.testForm.fieldToCheck.value;
var inChar = """;
var outChar = "'"
var newString = origString.split(inChar);
newString = newString.join(outChar);
document.testForm.fieldToCheck.value = newString;
}
</script>

<form name="testForm" method="post" action="">
<input name="fieldToCheck" type="text" id="fieldToCheck" value="Put quotes here and click tab" size="40" onBlur="replaceCharacters();">
</form>

Verify hex color string

<?php

//Check for a hex color string '#c1c2b4'
if(preg_match('/^#[a-f0-9]{6}$/i', $color)) //hex color is valid
{
//Verified hex color
}

//Check for a hex color string without hash 'c1c2b4'
else if(preg_match('/^[a-f0-9]{6}$/i', $color)) //hex color is valid
{
$fix_color = '#' . $color;
}

?>

Dynamic form input field value

<select class="select_field" name="select field" onchange="changeValue(this)">

<option value="Default Value" selected="selected">Default Value</option>

<option value="first">first</option>
<option value="second">second</option>

</select>

<input id="input_field1" value="" name="field1" type="text" />

<!--On Change Function for Select Field-->
<script type="text/javascript">

function changeValue(field){

inputField1 = document.getElementById("input_field1");

if (field.value != "Default Value"){
inputField1.value = "Changed It";
}
else {
inputField1 = "";
}

}
</script>

Clear Form Field

<script type
="text/javascript">
function clearMe(formfield){
if (formfield.defaultValue==formfield.value)
formfield.value = ""
}
</script>

<!--Just add this to your form field-->
onfocus="clearMe(this)"