Binary code to Gray code converter in javascript

<!-- Binary To Gray Code -->
<script type="text/javascript">
	function binaryToGray (number){
		if(isBinary(number)){
			var gray = "";
			gray = gray + number.charAt(0);
			for (var i = 1; i < number.length; i++) {
				if (number.charAt(i) == number.charAt(i-1)) {
					gray = gray + '0';
				}
				else{
					gray = gray + '1';
				}
			}
			document.getElementById('result').innerHTML  = gray;
		}else{
			document.getElementById('result').innerHTML  = "Input is not a binary number";
		}
	}
</script>
<div class="title">
	<h1>Binary To Gray Code</h1>
</div>

<form action="javascript:void(0);">
	<div class="text">
		<p>Convert numbers from binary (base 2) to gray code value.</p>
	</div>
	<label for="bin">Binary Number</label><br/>
	<input type="text" id="bin" name="bin" onkeyup="binaryToGray(this.value)"><br/>
	<label for="result">Gray Code Value</label><br/>
	<div id="result" class="result">NAN</div>
</form>