Advertisement
viditkothari

Assignment5

Sep 15th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.69 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!-- Segrate the numeric and non-numeric part -->
  3. <html>
  4.     <head>
  5.         <title>String Operations</title>
  6.         <script type="text/javascript">
  7.             function segregate()
  8.                 {
  9.                     var st=document.getElementById('userString').value;
  10.                     var stl=st.length;
  11.                     var nstr=new Array(2);
  12.                     nstr[0]="";
  13.                     nstr[1]="";
  14.                     for(var i=0;i<stl;i++)
  15.                        {
  16.                            if(isNaN(st.charAt(i)))
  17.                                nstr[0]=nstr[0]+st.charAt(i);
  18.                            else
  19.                                nstr[1]=nstr[1]+st.charAt(i);
  20.                        }
  21.                    console.log('Non-numeric part : ' + nstr[0] + ' & numberic : ' + nstr[1]);
  22.                }
  23.        </script>
  24.         <!-- The <style> section below is optional -->
  25.         <style type="text/css">
  26.             body{
  27.                 margin:0px;
  28.                 padding:0px;
  29.                 font-size:0.90em;
  30.                 font-family:Helvetica,sans-serif;
  31.             }
  32.             p{
  33.                 color:#FFF;
  34.                 background-color:#FF5533;
  35.                 width:120px;
  36.                 padding:5px 10px;
  37.                 margin:3px;
  38.                 text-align:center;
  39.             }
  40.             p:hover{
  41.                 background-color:#FF9955;
  42.                 cursor:pointer;
  43.             }
  44.         </style>
  45.     </head>
  46.     <body>
  47.         Enter any string of characters
  48.         <input type="text" id="userString" size="15"> <br />
  49.         <p onclick="segregate()">Segregate</p>
  50.     </body>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement