Add this script to the page
<script language="javascript" type="text/javascript">
function SetButtonStatus(sender, target)
if ( sender.value.length >= 12 )
document.getElementById(target).disabled = true;
<asp:TextBox ID="txtText" runat="server" onkeyup="SetButtonStatus(this, 'btnButton')">asp:TextBox>
<asp:Button ID="btnButton" runat="server" Text="Button" Enabled="false" />
This JavaScript validates the textbox and enables the button only if the textbox contains 12 characters.