View Single Post
Old 06-12-2009, 06:19 AM   #1 (permalink)
sandhyagupta
The Wanderer
 
sandhyagupta's Avatar
 
Join Date: Jun 2009
Posts: 20
Thanks: 4
sandhyagupta is on a distinguished road
Default How do i get to the last line

Hi tony, wild honey
i tried to code for the populating thing which i asked u before.
here s my code:
HTML Code:
<html>
  <head>
    <script type="text/javascript">
      function ValidateForm()
      {
        var data = document.frmSample.textarea1.value
        // Code for email validation
        var mysplitresult = data.split("\n");
        document.frmSample.contactname.value = mysplitresult[0]
        m = data.match(/\w+[.]?\w+[.]?\w*@\w+[.]\w+[.]?\w+/g);
        document.frmSample.email.value = m
        // code for website
        //n = data.match(/^((http|www):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+\.[^#?\s]+)(#[\w\-]+)?$/);
        //document.frmSample.web.value = n
        // Code for spliting the phone nos
        var n = mysplitresult[1]
        var mysplitresult1 = n.split("-");
        var length1 = mysplitresult1[2].length
        //document.write(length1);
        if(length1==10)
        {
          document.frmSample.mobile.value = mysplitresult1[2]
        }
        else
        {
          document.frmSample.phone.value = mysplitresult1[2]
        }

      }
    </script>
  </head>
  <body>
    <form action=" " method="POST" name="frmSample" onsubmit="return ValidateForm()">
      <table>
        <TR>
          <TD rowspan=10>
               TextArea<textarea name = 'textarea1' rows='28' cols='80'>
               </textarea>
           </TD>
           <TD>
               <input type=button value="click" onclick="ValidateForm()">
           </TD>
        </TR>
        <TR>
           <TD>
               Contact:<input type=text name="contactname" size=25>
           </TD>
        </TR>
        <TR>
           <TD>
               Email id:<input type=text name="email" size=25>
           </TD>
        </TR>
        <TR>
           <TD>
               Mobile no:<input type=text name="mobile" size=20>
           </TD>
        </TR>
        <TR>
           <TD>
               phone no:<input type=text name="phone" size=20>
           </TD>
        </TR>
      </table>
    </form>
  </body>
</html>
i dono wtz wrng in the match function for website.. itz nt displaying it.
n hoe do i get to the last line in the text n display the address.

few egs of wt i will be pasting in the text field are:
Code:
        Mr Rama Moorthy     
        +(91)-(80)-66491588
        info@novatechnosys.co.in 
        ramamoorthym@novatechnosys.co.in 
        No.729,1st Flr, Hal 2nd Stg, 8th Crs,11th Mn, Indiranagar, Bangalore - 560038



      
        Mr Srinivas(Managing Director)    
        +(91)-(80)-66492233
        srinivas@vyasam.com 
        chetan@vyasam.com 
        No. 1 & 2, 3rd Flr, Nr Sharavathi Hospital, Service Rd, Vijaynagar, Bangalore - 560040


          Mr Ananda Reddy K     
        +(91)-(80)-66366685
        ananda@srivatech.com
        www.srivatech.com
        No.430,, 5th Main, Shastri Nagar, Bangalore - 560028

Last edited by Salathe : 06-12-2009 at 01:20 PM. Reason: Wrapping HTML/Examples in code blocks.
sandhyagupta is offline  
Reply With Quote