Showing posts with label javascipt. Show all posts
Showing posts with label javascipt. Show all posts

Tuesday, January 4, 2011

Javascript Tips : How to create a pop up window using javacript in a Button?

How to create a pop up window when someone click on a button?
Here's a simple code the way I made it..
============================ ==================================
<html>
<head>
    <title>How to create pop up window using java script in a Button</title>
    <script language="javascript" type="text/javascript">
        function popup()
        {
            // change with your target URL
            popwindow = window.open("http://diary-of-programmer.blogspot.com/");
            return false;
        }
    </script>
</head>
<body>
    <input type="submit" value="pop up" onclick="return popup()"/>
</body>
</html>

============================== ==================================
we create a javascript function that we called "popup()". The statement window.open(), accept url parameter.
and then to call the function we utilized the button's onclick event.

That's is my simple way to create a pop up function... if you find this post help you, please leave a comment bellow.

Thank you...

Sunday, December 19, 2010

Javascript Tips : Javascript numeric only for input type text (TextBox)

How to create javascript numeric only input text (TextBox)?
I have made some script to solve this problem:
Here's a full example below:
================================================================
<html>
   <head>
   <title>
   Test Numeric Only
   </title>
   <script language=Javascript>

      function numericOnly(evt)
      {
         var key = (evt.which) ? evt.which : event.keyCode
         if (key > 31 && (key < 48 || key > 57)){
            document.getElementById("LabelValid").style.display = "block";
            return false;
        }
         document.getElementById("LabelValid").style.display = "none";
         return true;
      }
   </script>
   </head>
   <body>
      Numeric Only : <input id="TextBoxChar" onkeypress="return numericOnly(event)" type="text" name="TextBoxChar">
      <label id="LabelValid" style="display:none">(*)</label>
   </body>
</html>
================================================================
The "numericOnly" function is called by onkeypress event attribute of the input text (TextBox). The "numericOnly" function will return false if the user type a non-numeric character in the textbox. and I have added a validation label that will show "(*)" if the user type a non-numeric character, and will disappear if the user type a numeric value.

If you find my post helpful, please leave a comment...

Thank you....

Finally, C# 9 record, the equivalent of Scala's case class

While C# is a wonderful programming language, there is something that I would like to see to make our life programmer easier. If you are fam...