Click here to Skip to main content
15,921,179 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I am beginner for asp and js.I had complet the asp page designing with some of the textbox and dropdownlist.It is working properly.I need to validate each one of the field by using javascript.Kindly any one assist me.

Thanks
Posted
Comments
[no name] 1-Mar-12 7:14am    
Try downloading this book if you really wanna learn javascript..

http://yuiblog.com/assets/pdf/zakas-projs-2ed-ch18.pdf

you can visit
http://jquery.com/[^]
you can learn more about jquery validation.
 
Share this answer
 
Here is the sample code for JavaScript validation against ASP dropdownlist. Script will be:



JavaScript
function validateDropDown(obj){
        if(document.getElementById(obj).value=='')
        {
            alert('please select an item value under any group name.'); 
            return false;
        }
    }


In code behing, you have to attach the above JavaScript function with DropDownList control and a Button control that will submit the form data to the server

C#
protected void Page_Load(object sender, EventArgs e)
{

    DropDownList1.Attributes.Add("onchange", "javascript:return validateDropDown('" + DropDownList1.ClientID + "');");

    Button1.Attributes.Add("onclick", "javascript:return validateDropDown('" + DropDownList1.ClientID + "');");
}
 
Share this answer
 
v2
go visit
http://www.w3schools.com/jsref/
to learn the basics. good luck. :)
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900