| TechTasks.net |
The Blog is Moved to www.TechTasks.net
Design
In Coding Page Add Following code in Head Tag
<script type="text/javascript" >
function Validation()
{
//name
document.getElementById ('txtname');
if(name.value=='')
{
alert("Name Can't Blank");
getElementById ('txtname').focus();
return false;
}
//checking for only alphabets and name should be more than 4 char
var reforname=/^[A-Za-z]{4,50}$/;
var phone=document.getElementById('txtname').value;
if(phone.search(reforname))
//if(isNaN(phone))
{
alert("Enter Correct name");
document.getElementById ('txtname').focus();
return false;
}
//accepts only 10 digits
var reforphone=/^\d{10}$/;
var phone=document.getElementById('txtphone').value;
if(phone.search(reforphone))
{
alert("Enter Correct Phone No");
document.getElementById('txtphone').focus();
return false;
}
//Email Validation
var reforemail=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
var phone=document.getElementById('txtemail').value;
if(phone.search(reforemail))
{
alert("Enter Correct email");
document.getElementById('txtemail').focus;
return false;
}
//Dropdown list Validation
var dob=document.getElementById('ddldob');
if(dob.value=="select")
{
alert("select DOB");
return false;
}
//Radio Button Validation Here 'gender' is Group Name Of Radio Button
//if(document.getElementById('rb1').checked==false && document.getElementById ('rb2').checked==false)
if(document.form1.gender[0].checked==false && document.form1.gender[1].checked==false)
{
alert("select Gender");
return false;
}
//checkbox validation
if(document.getElementById('cb1').checked==false&& document.getElementById ('cb2').checked==false)
{
alert("select Alert Modes");
return false;
}
return true;
}
Add the Following Code In Page Load
//When Validation Function return True Then OnClick() is Fired (internally calls javaScript Function)
submit.Attributes.Add("OnClick","return Validation()");
Blog Archive
-
▼
2008
(33)
-
►
December
(14)
- Non Editable Rows in GridView
- Validate DropDownList inside GRIDVIEW
- .Net Keyboard Shortcuts
- Grid View Operataions
- FAQ'S & INTERVIEW TIPS
- C#.NET
- ASP.NET
- DOTNET FRAMEWORK
- Projects With Source Code
- Enter Text In Into Two TextBoxes At the Same Time
- Saving Uploaded file into Disk and displaying the ...
- Writing Connection string in web.config file
- Change GridView Row Color When MouseOver
- Working With Command Builder in ASP.NET
-
▼
November
(14)
- JavaScript Validatoin For Basic Controles in ASP.N...
- Dot Net - C#.Net(FAQ'S)
- Dot Net - Asp.Net - Basic II(FAQ'S)
- Dot Net - Asp.Net - Basic I(FAQ'S)
- Famous Books For .NET
- Connecting MySql With Asp.net Using ODBC Drivers
- Simple Calculator In Windows Application Using C#
- Mail Sending Using Net.Mail
- Select All And Delete Using CheckBox In GridView
- GridView DeleteAll,SelectAll,ClearAll(Server Side)...
- GridView Paging & Sorting
- GridView Update,Delete,Adding (Insert) Record...
- Alphabetical Paging in Gridview
- Connecting MySql With C# ASP.NET
-
►
December
(14)



0 comments: