"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Thursday, April 7, 2011

Simple javascript Email Validation

Hi *.*,
May some of u think whether my stack got empty or what isit??? ha ha ... I know it's a basic but it's important. On last day i c a post on fourms.asp.net asking for an email validation.he got more than 15 answers...Wow what a luck hand full of options. I gone through one by one.And almost all having a similar feature.Complicated !!!.All are touching the finishing lines but that not a good way , i feel so :( . that makes me this post.
Code:


<head runat="server">
    <title>Simple javascript Email Validation</title>
    <script type="text/javascript">
        function evalue(email) {
           // debugger;
            AtPos = email.indexOf("@")
            StopPos = email.lastIndexOf(".")
            Message = ""

            if (AtPos == -1 || StopPos == -1) {
                Message = "Not a valid email address"
            }

            if (StopPos < AtPos) {
                Message = "Not a valid email address"
            }

            if (StopPos - AtPos == 1) {
                Message = "Not a valid email address"
            }
            if (Message == "")
                return true;
            else
                alert(Message);
    }
        </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input id="txt" onblur="evalue(this.value)" type="text" />
    </div>
    </form>
</body>
</html>

Its simple and Sexy na, anyway i can feel it (:P
stay tune...

Have a nice day... 'N happy Coding :)

Wednesday, April 6, 2011

Create a Datatable and schema , A new approach

 Hi *.*,
In my last company my senior always use DATATABLE for Binding, i never seen he using DATASET.Difference i seen , by using tables u need to spend more time on coding,On Dataset it finished !!!. But table is fast than set....Any way i used both in my career depending upon needs.Last day my friend introduce me a new approach to Datatables, in one word i'm impressed.Here i'm presenting both.
Old way


    public void _pre()
    {
        try
        {
            DataTable dt = new DataTable("TableName");
            dt.Columns.Add("MyId", typeof(int));
            dt.Columns.Add("Name");
            dt.Columns.Add("Address");
            DataRow dr = new DataRow();
            dr[0] = 1;
            dr[1] = "Arun Aravind";
            dr[2] = "Kollam,Kerala,India";
            dt.Rows.Add(dr);
        }
        catch (Exception)
        {
           
            throw;
        }
    }

New Method




 
    public void _new()
    {
        try
       {
            DataTable dt = new DataTable
            {
                Columns ={
                {"Myid",typeof(int)},
                {"Name"},
                {"Address"}
                }
            };
            dt.Rows.Add(1, "Arun Aravind", "Kollam,Kerala,India");
        }
        catch (Exception)
        {
           throw;
        }
    }
 
Now u compare Both new method is so clean and sexy...Isit???

Hope u got it....Stay Tune... 
Have a nice day... 'N happy Coding :)

Saturday, April 2, 2011

Getting IP address through JQuery

Hi *.*,
In this tips,show how we could get the client IPAddress  with JQuery. Becase we know to get the client PC IPAddress usign ASP.NET

Using Server Side Code

Request.ServerVariables["REMOTE_ADDR"];

Using Jquery
$(function() {
    $('a').click(function()
{
    $.getJSON("http://jsonip.appspot.com?callback=?",function(ipadd){
        alert( "Your IPAddress is : " + ipadd.ip);
    });
     });
});

in above code,i have done a simple query the IPAddress using JSON to another IPaddress provider server. the callback function will return the Your PC IP Address.
Have a nice day... 'N happy Coding :)