<script type="text/javascript"> function checkAge() { var today = new Date(); var d; var dateEntered = document.getElementById('<%=TextBox7.ClientID %>').value; var objRegExp = /\d{1,2}\-\d{1,2}\-\d{4}$/ if (!objRegExp.test(dateEntered)) { alert('Date not in correct format'); return false; } d = dateEntered.split('-'); var yearEntered = parseInt(d[2]); var nowYear = parseInt(today.getFullYear()); var age = nowYear - yearEntered; alert(age); //return false; } </script>
<asp:TextBox ID="TextBox7" onblur="Javascript:checkAge();" runat="server" OnTextChanged="TextBox7_TextChanged" Width="150px"></asp:TextBox>
protected void TextBox7_TextChanged(object sender,EventArgs e) { // you can check for null before assigning (optional) yourtextbox.text=TextBox7.Text; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)