Dear Team,
how to set blank and input validation in asp.net 4.0 using javascript
on change event, clickevent or which bet for client and server side
dharmendr says: Hi pratikshir, Refer the below sample. Using JavaScript 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> function BlankCheck(ele) { if (document.getElementById(ele.id).value == '') { alert('Name can\'t be blank'); } } </script> </head> <body> <form id="form1" runat="server"> <div> <input name="txtName" type="text" id="txtName" onkeyup="BlankCheck(this);" /> </div> </form> </body> </html> Demo Using jQuery 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript"> $(function () { $('#txtName').on('keyup', function () { if ($(this).val() == '') { alert('Name can\'t be blank'); } }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <input name="txtName" type="text" id="txtName" /> </div> </form> </body> </html> Demo
Hi pratikshir,
Refer the below sample.
Using JavaScript
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
head
runat
"server"
title
></
script
type
"text/javascript"
function BlankCheck(ele) {
if (document.getElementById(ele.id).value == '') {
alert('Name can\'t be blank');
}
</
body
form
id
"form1"
div
input
name
"txtName"
"text"
onkeyup
"BlankCheck(this);"
/>
Demo
Using jQuery
src
"https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"
$(function () {
$('#txtName').on('keyup', function () {
if ($(this).val() == '') {
});
How to highlight or error message near by control
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.