Sai Stuff to Developers

April 30, 2008

Java Script code For Numeric Validation

Filed under: DotNet — tosaik @ 1:26 pm
Tags:

In your html page add the control you want to validate but for this sample i used textbox to demonstrate this code,
in my textbox control i used onkeyup event to validate whether recently entered charecter is numeric or not.
so you can call this Javascript code as your requirement in your project.

Test.html
————

<input type=”text” id=”txt” name=”txt” onkeyup=”txtValidate(this.id)”/>
JavaScript Code
——————-

    function txtValidate(txtid)
    {
    var ok=0;
    var a=document.getElementById(txtid).value;
       
       for(var i=0;i<=a.length-1;i++)
      {
        var j=a.charCodeAt(i);
           for(var k=48;k<=57;k++)
        {
          ok=0;
          if(k==j)
          {
            ok=1;
            break ;
          }
        }
       
      }
      if(ok==0)
      {
        alert(“Only Numeric Values Allowed”);
        document.getElementById(txtid).value=””;
        for(var i=0;i<a.length-1;i++)
        {
         var j=a.charCodeAt(i);
           for(var k=48;k<=57;k++)
        {
          ok=0;
          if(k==j)
          {
           document.getElementById(txtid).value+=a.charAt(i);
             }
        }
        
        }
      }
    }

 

I hope this code helps you.

Thank you….,

April 10, 2008

Programmatically Manipulating Clip Board Functionality using .Net

Filed under: DotNet — tosaik @ 3:48 pm
Tags:

Using dot net libraries we can do the functionalities like coping any data to the clipboard with single click in our .net application and you can paste it in any application including no dot net applications.

 

Now I am showing a simple application using vb.net.

 

Step-1:  Design the form as the image shown below.

 

Step-2: In Copy buttons Click event write this code.

 

 

 

 

Step-3: Similarly in Paste buttons Click event write this code.

 Step-4: Now run the application, you can see the out put form as shown below  

 

 

 

Step-5:  Now write some data like this..

 

And click copy button.

 

 
 

 Bye Cheers. 🙂

 

 Bye Cheers. 🙂

 

 

 

 

Blog at WordPress.com.

%d bloggers like this: