最简单的解决方案:
<input name="ContentInclude:borderspecs" type="text" maxlength="200"
id="ContentInclude_borderspecs" tabindex="5" style="width:500px"
onkeyup="javascript:changeBorderColor(this);">
JS代码:
<script>
function changeBorderColor(elem){
var template = document.getElementById('sampletemplate');
if (elem.value.match(/^\#([\dabcdef]{3}|[\dabcdef]{6})$/i)) { // HEX code
template.style.borderColor = elem.value;
}
// more else if to match other possible values
else { // reset to default
template.style.borderColor = null; // or "black"
}
}
</script>
// 编辑所以它改变了模板预览的颜色div#sampletemplate