Html Code:
<--h1>Search By Name<--/h1>
<--ul>
<--asp:TextBox ID="TextBox1" runat="server" Width="123px"><--/asp:TextBox>
<--asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="~/images/search.JPG" onclick="ImageButton1_Click"
OnClientClick=" return validate()" Height="21px" Width="29px"/>
<--/ul>(ex: Obama)
Javascript code:
<--script language="javascript" type="text/javascript">
function validate(){
if(document.getElementById("<%=TextBox1.ClientID%>").value=="")
{
alert("Please enter an associate name!");
document.getElementById("<%=TextBox1.ClientID%>").focus();
return false;
}
var digits = "0123456789";
var temp;
for(var i = 0; i < document.getElementById("<%=TextBox1.ClientID %>").value.length; i++){
temp = document.getElementById("<%=TextBox1.ClientID%>").value.substring(i, i + 1);
if (digits.indexOf(temp) != -1) {
alert("Please enter a valid value!");
document.getElementById("<%=TextBox1.ClientID%>").focus();
return false;
}
}
var charc = "~`!@#$%^&*()_+-=|\"':;{}[]?/><.,*";
var tempo;
for(var j = 0; j < document.getElementById("<%=TextBox1.ClientID %>").value.length; j++){
tempo = document.getElementById("<%=TextBox1.ClientID%>").value.substring(j, j + 1);
if (charc.indexOf(tempo) != -1) {
alert("Please enter a valid value!");
document.getElementById("<%=TextBox1.ClientID%>").focus();
return false;
}
}
return true;
}
<--/script>
Thursday, January 29, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment