473,574 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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).P lease 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 1404
dlite922
1,584 Recognized Expert Top Contributor
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
3467
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 write a program or a project of some sort, how do you actually start. Picture this, you know what you want the program to do (its features), you have...
8
2498
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 multiprotocol, but do not want to write code for all protocols which I want to support. I plan I give a interface and others give a module which implements...
8
2436
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 better and more efficient way to write this program. //This program calculates the users Gross Pay and subtracts the tax based off of Marital...
7
3420
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 and create an assembly include file with the structure member offsets defined. The problem is that the structure offsets are a complicated...
3
11312
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 zhonghua_1999@163.com thank you in advance.
0
909
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 set control properties from code. I would like to do something like Dim myControl as New UI.Webcontrols.image
3
5015
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 settings for the default web service user account so that sounds go through a sound card rather than the on-board sound. I can do this simply when...
3
1898
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 Visual SourceSafe be used with PHP projects? Full details: I was looking for a way to manage the changes to my PHP coding projects. I currently use...
6
1647
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 run-time or not. The program should work with any mathematical function provided by users. Let's take an example in the C language:
0
1348
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 http://developers.sun.com/solaris/articles/mixing.html
0
7807
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7730
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8058
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5624
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2249
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1061
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.