For checking empty Textbox
<script type="text/javascript">
function validate() {
if (document.getElementById("<%=txtname.ClientID%>").value == "") {
alert('textbox should not be empty...');
return false;
}
if (document.getElementById("<%=txtpwd.ClientID%>").value == "")
{
alert('textbox should not be empty...');
return false;
}
return true;
}
</script>
in button click event
<asp:Button ID="submit" runat="server" Text="Submit" OnClientClick="return validate()"/>
For checking Length of textbox value
if (document.getElementById("<%=txtpwd.ClientID%>").value.length<10) {
alert('please enter valid mobile number.');
return false;
}
return true;
checking Isnumeric or not
var data = document.getElementById('<%=txtpwd.ClientID %>').value;
var filter = /^[0-9]+$/;
if (!filter.test(data)) {
alert("Please enter alphanumeric only");
document.getElementById('<%=txtpwd.ClientID %>').value = "";
document.getElementById('<%=txtpwd.ClientID %>').focus();
return false;
}
var filter = /^[a-zA-Z]+$/; //for charecters only.
<script type="text/javascript">
function validate() {
if (document.getElementById("<%=txtname.ClientID%>").value == "") {
alert('textbox should not be empty...');
return false;
}
if (document.getElementById("<%=txtpwd.ClientID%>").value == "")
{
alert('textbox should not be empty...');
return false;
}
return true;
}
</script>
in button click event
<asp:Button ID="submit" runat="server" Text="Submit" OnClientClick="return validate()"/>
For checking Length of textbox value
if (document.getElementById("<%=txtpwd.ClientID%>").value.length<10) {
alert('please enter valid mobile number.');
return false;
}
return true;
checking Isnumeric or not
var data = document.getElementById('<%=txtpwd.ClientID %>').value;
var filter = /^[0-9]+$/;
if (!filter.test(data)) {
alert("Please enter alphanumeric only");
document.getElementById('<%=txtpwd.ClientID %>').value = "";
document.getElementById('<%=txtpwd.ClientID %>').focus();
return false;
}
var filter = /^[a-zA-Z]+$/; //for charecters only.
No comments:
Post a Comment