Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How to validate username?this my register.jsp

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to validate username?this my register.jsp

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page import="java.util.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.text.*" %>
    <%@ page import="java.util.Date" %>

    <%@page import="org.apache.catalina.Session"%><html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>registration form</title>
    </head>

    <body bgcolor="#FFFFF0">
    <form name="f1" method ="post" action="RegisterSave" onsubmit="javascript:return validateForm();">

    <p align="center">UserName:&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;
    <input type=text name='username' size="20"></p>
    <p align="center">Password:&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="password" name ="password" size="20"></p><br>
    <p align="center">ConfirmPassword:&nbsp;
    <input type="password" name="confirmpassword" size="20"></p><br>
    <p align="center">FirstName:&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type ="text" name="firstname" size="20"></p><br>
    <p align="center">LastName:&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type ="text" name="lastname" size="20"></p><br>
    <p align="center">Age:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type ="text" name="age" size="20"></p><br>
    <p align="center">DOB:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;
    <select name="dob">
    <option>01</option>
    <option>02</option>
    <option>03</option>
    <option>04</option>
    <option>05</option>
    <option>06</option>
    <option>07</option>
    <option>08</option>
    <option>09</option>
    <option>10</option>
    <option>11</option>
    <option>12</option>
    <option>13</option>
    <option>14</option>
    <option>15</option>
    <option>16</option>
    <option>17</option>
    <option>18</option>
    <option>19</option>
    <option>20</option>
    <option>21</option>
    <option>22</option>
    <option>23</option>
    <option>24</option>
    <option>25</option>
    <option>26</option>
    <option>27</option>
    <option>28</option>
    <option>29</option>
    <option>30</option>
    <option>31</option>
    </select>
    <select name="mob">
    <option>01</option>
    <option>02</option>
    <option>03</option>
    <option>04</option>
    <option>05</option>
    <option>06</option>
    <option>07</option>
    <option>08</option>
    <option>09</option>
    <option>10</option>
    <option>11</option>
    <option>12</option>
    </select>
    <select name="yob">
    <option>1980</option>
    <option>1981</option>
    <option>1982</option>
    <option>1983</option>
    <option>1984</option>
    <option>1985</option>
    <option>1986</option>
    <option>1987</option>
    <option>1988</option>
    <option>1989</option>
    <option>1990</option>
    <option>1991</option>
    <option>1992</option>
    <option>1993</option>
    <option>1994</option>
    <option>1995</option>
    </select></p><br>
    <p align="center">Designation:&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type ="text" name="designation" size="20"></p><br>
    <p align="center">TeamName:&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;
    <input type ="text" name="teamname" size="20"></p><br>
    <table align="center">
    <tr>
    <td>Terms and Condition:</td>
    <td><textarea rows="10" cols="20" name="term" >1.The registration only for SourceTrace Employee 2.Rest of the members please neglect this form.</textarea></td>
    </tr>
    </table>
    <p align="center">
    <input type="submit" name="submit" value="I Accept,Create My Account"></p>

    </form>



    <script type="text/javascript">

    function validateForm(){
    if(document.f1.username.value==""){
    alert("User Name shouldnt be left blank");
    document.f1.username.focus();
    return false;
    }

    if((document.f1.password.value=="") |(document.f1.confirmpassword.value=="") ){
    alert("User password shouldnt be left blank");
    document.f1.password.focus();
    return false;
    }

    if(document.f1.password.value != document.f1.confirmpassword.value){
    alert("Password doesnt match");
    document.f1.password.focus();
    return false;
    }
    if(document.f1.firstname.value==""){
    alert("User FirstName shouldnt be left blank");
    document.f1.firstname.focus();
    return false;
    }
    if(document.f1.lastname.value==""){
    alert("User LastName shouldnt be left blank");
    document.f1.lastname.focus();
    return false;
    }
    if(document.f1.age.value==""){
    alert("User Age shouldnt be left blank");
    document.f1.age.focus();
    return false;
    }
    if(document.f1.designation.value==""){
    alert("User Designation shouldnt be left blank");
    document.f1.designation.focus();
    return false;
    }
    if(document.f1.teamname.value==""){
    alert("User TeamName shouldnt be left blank");
    document.f1.teamname.focus();
    return false;
    }

    }

    </script>
    </body>
    </html>
    Last edited by surendran610; August 18th, 2011 at 02:50 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,343
    Thanks
    182
    Thanked 831 Times in 774 Posts
    Blog Entries
    5

    Default Re: How to validate username?this my register.jsp

    What's your question? What did you try? What didn't work? All you did was dump some code. Suggested reading: How To Ask Questions The Smart Way

  3. #3
    Junior Member
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to validate username?this my register.jsp

    my question is "How to validate the existing username in database?"

Similar Threads

  1. Replies: 1
    Last Post: May 20th, 2011, 03:58 AM
  2. How to validate a given URL
    By HelloAll in forum AWT / Java Swing
    Replies: 2
    Last Post: March 1st, 2011, 12:25 AM
  3. Database settings (username and password)
    By palooza in forum JDBC & Databases
    Replies: 3
    Last Post: February 24th, 2011, 12:53 AM
  4. Connecting to a HTTPS URL using username and password
    By explore in forum Java Networking
    Replies: 1
    Last Post: October 18th, 2010, 04:57 PM
  5. Cash Register Exercise
    By Consus in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 19th, 2010, 10:52 PM