473,320 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how can change the control of aPHP code to JS code write in same program?

here my problem is ,when i check if the username is exist in the DB ,there must have one option to re enter it.In this program when i make an attempt to reenter the username.it will clear all the other contents also(emailid).Please help me to locate the cursor in username field only and do not change the other fields.
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <script language = "Javascript" type="text/javascript">
  3. /**
  4.  * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
  5.  */
  6.  
  7. function echeck(str) {
  8.  
  9.         var at="@"
  10.         var dot="."
  11.         var lat=str.indexOf(at)
  12.         var lstr=str.length
  13.         var ldot=str.indexOf(dot)
  14.         if (str.indexOf(at)==-1){
  15.            alert("Invalid E-mail ID")
  16.            return false
  17.         }
  18.  
  19.         if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
  20.         {
  21.            alert("1.Invalid E-mail ID")//@not come,first char is @ or len @ is last char
  22.            return false
  23.         }
  24.  
  25.         if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
  26.             alert("2.Invalid E-mail ID")
  27.             return false
  28.         }
  29.  
  30.          if (str.indexOf(at,(lat+1))!=-1)//when more @ come together
  31.          {
  32.             alert("3.Invalid E-mail ID")
  33.             return false
  34.          }
  35.  
  36.          if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)//@. or .@ not come tgthr or 
  37.          {
  38.             alert("4.Invalid E-mail ID")
  39.             return false
  40.          }
  41.  
  42.          if (str.indexOf(dot,(lat+2))==-1)//if . is not come after @abc eg:meg@abc(is false)meg@ad(false)meg@gmail.com(correct)
  43.          {
  44.             alert("5.Invalid E-mail ID")
  45.             return false
  46.          }
  47.  
  48.          if (str.indexOf(" ")!=-1){
  49.             alert("6.Invalid E-mail ID")
  50.             return false
  51.          }
  52.  
  53.           return true                    
  54.     }
  55.  
  56. function ValidateForm(){
  57.     alert("fn");
  58.     var emailID=document.frmSample.txtEmail
  59.     var  name=document.frmSample.txtname
  60.     if ((emailID.value==null)||(emailID.value=="")){
  61.         alert("Please Enter your e mail")
  62.         emailID.focus()
  63.         return false
  64.     }
  65.     if (echeck(emailID.value)==false){
  66.         emailID.value=""
  67.         emailID.focus()
  68.         return false
  69.     }
  70.     if ((name.value==null)||(name.value=="")){
  71.         alert("Please Enter your name")
  72.         emailID.focus()
  73.         return false
  74.     }
  75.  
  76.     return true
  77.  }
  78. </script>
  79.  
  80. <?php
  81. $result="";
  82. $sql1="";
  83. include_once("includes/config.php");
  84. $tableobj=new dataBase();
  85. if(isset($_POST['Submit']))
  86.  
  87. {/*value="<?php if($_REQUEST['name']){ echo $_REQUEST['name']; } ?>"*/
  88.  
  89.     $name=mysql_escape_string(trim($_POST['txtname']));
  90.     $emailid=trim($_POST['txtEmail']);
  91.     echo $name;
  92.     $result="SELECT * FROM admin WHERE (Admin_username)='".$name."'";
  93.     $row=$tableobj->selectQry($result);
  94.     $p=count($row);
  95.     echo $p;
  96.     echo"******";
  97.     $no=0;
  98.     for($i=0;$i<count($row);$i++)
  99.     {
  100.         $no++;
  101.  
  102.         echo $no;
  103.         echo"#######";
  104.     }
  105.  
  106.  
  107.  
  108.      if($no==0)
  109.      {
  110.  
  111.         $sql1="INSERT INTO admin(Admin_name,Admin_username,Admin_passwd,email_id) VALUES('kamal','".$name."','megha','".$emailid."')";
  112.                 if(!mysql_query($sql1,$con))
  113.                 {
  114.                     echo"error".mysql_error();
  115.  
  116.                 }
  117.  
  118.                 mysql_close($con);
  119.      }
  120.      if($no>0)    
  121.     {
  122.         echo"username existing";
  123.         //header("location:email.php");
  124.         //exit();
  125.  
  126.     }
  127. }
  128.  
  129.  
  130. ?>
  131. <body>
  132. <form name="frmSample" method="post" action="email.php" onSubmit="return ValidateForm()">
  133.                 <p>Enter name : 
  134.                   <input type="text" name="txtname" >
  135.                 </p>
  136.                 <p>
  137.  
  138.                 </p>        
  139.                 <p>Enter an Email Address : 
  140.                   <input type="text" name="txtEmail">
  141.                 </p>
  142.  
  143.  
  144.  
  145.                   <input type="submit" name="Submit" value="Submit">
  146.                 </p>
  147.               </form>
  148. </body>
  149. </html>
  150.  
Nov 3 '10 #1
1 1394
dlite922
1,584 Expert 1GB
Line 66 above. It looks like you're setting the emailid to "" (blank string).

Don't you want to take that out?

I don't see any other "content" besides that.

You should understand every line of your code, if not ask us or google it. There's no point in listing your problems if you don't know what your own program does, right?

Good luck,


Dan
Nov 3 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

33
by: Nick Evans | last post by:
Hello there, I have been on and off learning to code (with python being the second language I have worked on after a bit of BASIC). What I really want to know is, if you are going to actually...
8
by: Zheng Da | last post by:
I don't know where should I ask the question, so send the email to this group. I choose this group, because I want to write the program with c++ :) I want to write a program which support...
8
by: brian.digipimp | last post by:
I turned this in for my programming fundamentals class for our second exam. I am a c++ newb, this is my first class I've taken. I got a good grade on this project I'm just wondering if there is a...
7
by: Randy Yates | last post by:
Hi, I work in an embedded environment in which we often use a mix of C and assembly code. Thus a recurring requirement is to be able to take a C header file with structure definitions as input...
3
by: | last post by:
Hi,all I want to change Control's size&location in runtime ,(C#) but i dont know how to do! :(so, can you provide me with document about this. my email: zhonghua@rinpak.com.cn ...
0
by: MS Newsgroups | last post by:
Hi, I am trying to create a table that adds cells through a for each loop. In each cell i would like to create a image control. I have manged to get the control created, but my problem is how to...
3
by: pealy2 | last post by:
Sorry if this is in the wrong group, I've searched long & hard without finding anything even slightly useful. (recommendations for a more relevant group gratefuly received) I need to change the...
3
by: Dave Smithz | last post by:
Hi there, Summary: I'm looking for a good open source, Windows Change control program. What are people using for there PHP projects? Is there a clear leader for this? Can programs like MS...
6
by: trungthanh78 | last post by:
Hello everyone, I'm totally new to the group and I would like to learn from you. Thank you in advance! I need to write a program to track whether a mathematical function has changed during...
0
by: John Scheldroup | last post by:
Source: Article Mixing C and C++ Code in the Same Program By Stephen Clamage, Sun Microsystems, Sun ONE Studio Solaris Tools Development Engineering ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.