Welcome to my blog.

Post on this blog are my experience which I like to share. This blog is completely about sharing my experience and solving others query. So my humble request would be share you queries to me, who knows... maybe I can come up with a solution...
It is good know :-)

Use my contact details below to get directly in touch with me.
Gmail: nadarmuthukumar1987@gmail.com
Yahoo: nadarmuthukumar@yahoo.co.in

Apart from above people can share their queries on programming related stuff also. As me myself a programmer ;-)
Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Pan Card Validation in C#

Add below code to your head section of page under script tag.
function chkPANLen(sender, args)
        {
            var PANno = document.getElementById("").value;
            var pan = /^([A-Z a-z]{5})+([0-9]{4})+([A-Z a-z]{1})$/;
            if (!(PANno.match(pan)))
            {
                args.IsValid = false ;
                return;
            }
            args.IsValid = true ;
        }
Below is the code to validate your control
Pan No. :
                   








Reference: Muthukumar (http://nadarmuthukumar.blogspot.in)

Call Javascript from Code Behind

There are time when you need to call your Javascript function from code behind.
You can achieve the same using below code,

Javascript function to call
function ConfirmBox(objMsg)
    {
        if(confirm(objMsg))
        {
            alert('test');
            return true;
        }
        else
        {
            return false;
        }
    }

C# Code Behind
this.ClientScript.RegisterStartupScript(typeof(Page), "Popup", "ConfirmBox('" + str + "');", true);

Or
this.ClientScript.RegisterStartupScript(typeof(Page), "Popup", "alert('" + str + "');", true);
Reference: Muthukumar (http://nadarmuthukumar.blogspot.in)

Check Value is Integer

function ValidateInteger(Obj)
    {
        if(Obj.toString().indexOf(".") > -1)
        {alert('Kindly enter amount in multiples of 1.'); return false;}

        if(parseInt(Obj)==NaN)
        {alert('Invalid Amount.'); return false;}
        
        return true;
    }
Reference: Muthukumar (http://nadarmuthukumar.blogspot.in/)

Validate RadioButton in GridView, DataGrid, DataList

JavaScript inside Script Tag on your page.
    function ValidateSelection()
    {
        var grid = document.getElementById("");
        var Selected = 0;
        for (i = 1; i < grid.rows.length; i++)
        {
            if(grid.rows[i].getElementsByTagName("input")[0] != null
                && grid.rows[i].getElementsByTagName("input")[0].type == "radio" 
                && grid.rows[i].getElementsByTagName("input")[0].checked)
                {
                    Selected = 1;
                    break;
                }
        }
        if(Selected==0)
        { alert('Please select any row to proceed.'); return false; }
        else
        { return true; }
    }
Designer

Twitter Delicious Facebook Digg Stumbleupon Favorites More