Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions REGISTARTION FORM VALIDADTION

Have Programming Question? Ask it here!
 
 
 


kamal chanda
REGISTARTION FORM VALIDADTION
1 Answer(s)      a year and 10 months ago
Posted in : JavaScript Questions


Hiee..
actually i have developed a sign up page where the details get stored in to database after registration. So i want to validate the user details during the signing up process whether the user name is already registered or not... if the user name exist in the data base i should get an alert that user name is already regstrd please choose new username... pls help me...


MY CODE

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script>
function validateForm()
{
//var x=document.forms["myform"]["funame"].value;
var x=document.getElementById("funame").value;
if (x==null || x=="")
  {
  alert("First name must be filled out");
  return false;
  }

  var a=document.getElementById("luname").value;
  if (a==null || a=="")
  {
  alert("Last name must be filled out");
  return false;
  }
  var y=document.getElementById("password").value;
  var z=document.getElementById("cpassword").value;
  if(y!=z)
  {
alert("Idiot password and confirm password doesnot match");
return false;
  }
}
</script>
</head>
<body bgcolor=#1F3D4C>
<form name="myform" action="urlpat" method="post" onsubmit="return validateForm()">
<div id="container" style="width:500px">

<div id="header" style="background-color:#66293D;">
<h1 style="margin-bottom:0;width=1500;">SPARK REGISTARTIONS</h1></div>

<table align="center">
<th><h1>SIGN UP<h1></th>

<tr><td>enter first name:</td><td><input type="text"  name="funame" id="funame"></td></tr>
<tr><td>enter last name:</td><td><input type="text" name="luname" id="luname"></td></tr>
<tr><td>enter user name:</td><td><input type="text" name="username"></td></tr>
<tr><td>choose password:</td><td><input type="password" name="password" id="password"></td></tr>
<tr><td>confirm password:</td><td><input type="password" name="cpassword" id="cpassword"></td></tr>
<tr><td>enter fathers name:</td><td><input type=text name="fathername"></td></tr>
<tr><td>enter ur emailid</td><td><input type="text" name="emailid"></td></tr>
</table><center>
<h4>Gender</h4>
Male<input type="radio" name="gender" value="male">
Female <input type="radio" name="gender" value="female"><br>
<h4>select your country</h4>
<select name="country">
<option value="india">INDIA</option>
<option value="australia">AUSTRALIA</option>
<option value="usa">USA</option>
<option value="srilanka">SRILANKA</option>
<option value="france">FRANCE</option>
<option value="china">CHINA</option><br>
</select>
<table align="center">
<th><h4>select your programming skills</h4></th>
<tr><td><input type="checkbox" name="programming concepts" value="java">java</td></tr>
<tr><td><input type="checkbox" name="programming concepts" value="c">c</td></tr>
<tr><td><input type="checkbox" name="programming concepts" value="c++">c++</td></tr>
<tr><td><input type="checkbox" name="programming concepts" value=".net">MS.NET</td></tr>
</table>
<input type="submit" value="submit"></br>
<h4>If Registered User please Sign In</h4>
<a href="signin.html" "background-color:#002233;">SIGN IN</a>
</div>
</form></center>
</body>
</html>

Advertisement
View Answers

November 2, 2012 at 3:52 PM


Here is a code that validates fields of html form using javascript.

<html>
    <h2>Form Validation</h2>
        <script language = "Javascript">
          function checkEmail() {
            if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value)){
            return true;
            }
            return false; 
          }
          function checkName(str){
              var re = /[^a-zA-Z]/g
              if (re.test(str)) return false;
              return true;
            }
            function checkAddress(str){
              var re = /[^[a-z][A-Z][0-9]]/g
              if(re.test(str)) return false;
              return true;
            }
          function validate(){
            var emailID=document.form.email;
              var nn=document.form.name;
                var add=document.form.address;

            if((nn.value==null)||(nn.value=="")){
            alert("Please Enter your Name!")
            nn.focus();
            return false
            }
            if(checkName(nn.value)==false){
            nn.value=""
            alert("Invalid Name!");
            nn.focus()
            return false
            }
            if((emailID.value==null)||(emailID.value=="")){
            alert("Please Enter your Email ID!")
            emailID.focus()
            return false
            }
            if (checkEmail(emailID.value)==false){
            emailID.value=""
            alert("Invalid Email Adderess!");
            emailID.focus()
            return false
            }
            if ((add.value==null)||(add.value=="")){
            alert("Please Enter your Address!")
            add.focus()
            return false
            }
            if (checkAddress(add.value)==false){
            add.value=""
            alert("Invalid Adderess!");
            add.focus()
            return false
            }
            if(document.form.qua.selectedIndex==""){
            alert ( "Please select your qualification!" );
     return false;  
    }
            return true
          }
        </script>
        <form name="form" method="post" onSubmit="return validate()">
        <pre>
        Enter Name:              <input type="text" name="name" size="30"><br>
        Enter an Email Address : <input type="text" name="email" size="30"><br>
        Enter Address            <textarea name="address" rows="5" cols="23"></textarea><br>
        Select Qualification:    <select name="qua">
                                 <option value="BTech">BTech</option>
                                 <option value="MBBS">MBBS</option>
                                 <option value="MBA">MBA</option>
                                 <option value="MCA">MCA</option>
                                 </select><br>

        <input type="submit" name="Submit" value="Submit">
        </pre>
        </form>
</html>


Related Tutorials/Questions & Answers:
REGISTARTION FORM VALIDADTION
REGISTARTION FORM VALIDADTION  Hiee.. actually i have developed a sign up page where the details get stored in to database after registration. So i...;body bgcolor=#1F3D4C> <form name="myform" action="urlpat" method="post
form
form   Can I prevent a form from being submitted again
Advertisements
form validation
form validation  how the form validation is done in jsf form using javaScript
print a form of *
print a form of *   * *** ***** ******* ********* ******* ***** *** *   Post the format properly
Multipage form
Multipage form  I have a multipage form in php with 2 pages wnhen i submit the form data from both the pages should go in database how should i pass teh data from 1st page to 2nd page and then put the entire form data in mysql
jsp form
jsp form  hi sir, one got one got in jsp form after entering the data into the form the data is not saving in the database i will send you code of two forms if dnt understand my problem
submit a form
submit a form  How can we submit a form without a submit button
Form handling
Form handling  I created a spring project. I created a jsp...;form:form name="loginForm" modelAttribute="loginForm" method="get"> <...;/td> <td> <form:input path="username"/>
Form Validation
Form Validation  Java script validation for checking special characters and white spaces and give an alert.Please help me urgent Thanks in advance
<form id=
form id  sir, <form id="reg1" action="../UploadingCtrl" method="post" enctype="multipart/form-data" name="form1"> this action page can't get String tp = request.getParameter("indegrates"). i wrote article upload
<form id=
form id  sir, <form id="reg1" action="../UploadingCtrl" method="post" enctype="multipart/form-data" name="form1"> this action page can't get String tp = request.getParameter("indegrates"). i wrote article upload
Form validation
Form validation  Hi Everyone Can someone assist me with a complete code to validate a form. e.g where the user must insert an ID number it should check if the user entered the correct data and within a valid range. This must
PHP form
PHP form  Hi Sir/Madam, I am developing an attendance form using php, which displays the name and ID of a Employees which are fetched from Db and I... form and update them to respective coloumn... Please any one help mo out please
other form
other form  Can I write this code in other form: if (quantity>=5) { System.out.println("Congrats!! You get a discount of 5%."); } else { System.out.println("you can avail a discount of 5% when you make a purchase of 5 items
Employee form
Employee form  In employee form emp Id id after any data iserted is incremented for oher data insertion. insert, delete, update buttons when we cleak the select buttoun then the created table data iserted automaticaly
struts form
struts form  Hi, This is Rajesh.I'm creating struts form in jsp.i have two textboxes in my jsp.During Jsp page loading focus will automatically should come to second textbox(That means during page loading cursor automatically
login form
login form  sir my next form consists logout button when i click on it it showing login form but next form window is not closing but the components prepsent in that form are getting clearedup using frameobject.setVisible(false
login form
login form  sir my next form consists logout button when i click on it it showing login form but next form window is not closing but the components prepsent in that form are getting clearedup using frameobject.setVisible(false
Login Form
of +,on clicking which a login form appears. Only the middle column is different
Login Form
of +,on clicking which a login form appears. Only the middle column is different
jsp form
jsp form  hai... GoodEvening I have one doubt on jsp.please wil u clarify it. how to move one jsp form to another jsp form with out using forward...)form1.jsp: <html> <form method="post" action="form2.jsp"> <table>
form submission
form submission  I have two pairs of textboxes...( so in total 4...("Enter text4 value!"); return false; } return true; } </script> <form name="form" method="post" onsubmit="return validate();"> <input type="text
form validation
form validation  <form name="form" method="post" action="process.php" onsubmit="return validate(); "> <table align="center" border="1px" bgcolor="orange" > <tr><td>username:</td><
about form
about form  how to dynamically increase the textbox in the 2nd form when i gave any value in textbox of form1 . if i gave 5 in the textbox of form1 , totally 5textbox have to be created in form2.   import javax.swing.
dynamic form
dynamic form  I need to make a dynamic form using php, for example, i... button wich once clicked we have a new list created on the same form. Thank you...); } } </script> <form method="post" action="" name="form1"> <
Dynamic form
Dynamic form  I need to make a dynamic form using jsp for example, i will need a list of items which when we select one option another list... clicked we have a new list created on the same form. Thanks for your help  
jsp form
jsp form  hi i have one excuted jsp form.and in that the data should be dispaly on another jsp form.please help me thanks in advance   Hi Friend, Try this: 1)form1.jsp: <html> <form method="post" action
registration form
="center" border=0&gt; &lt;form name="f1" action="CreateUser
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation
The form tag
In this tutorial, you will learn about Spring form tag
form field issue
form field issue  how to set the values in form field and form field drop down (doc 2007) using Apache poi
focus to the first form field
focus to the first form field  How do I set the focus to the first form field
focus to the first form field
focus to the first form field  How do I set the focus to the first form field
the focus to the first form field
the focus to the first form field   How do I set the focus to the first form field
Action without a form.
Action without a form.  Can I have an Action without a form
Login form and registration
Login form and registration  I need a complete code for ligin and new user registration form and validation
php form post to mysql
php form post to mysql  How to post data into mysql database from the PHP post data form
HTML Form data into .CSV?
HTML Form data into .CSV?  how to store data from html form to csvfile in java
create a form using struts
create a form using struts  How can I create a form for inputting text and uploading image using struts
How to create form in Swings
How to create form in Swings  How to create registration, login and question form in Java Swing?   Creating different forms in Java Swing - Examples how to create registration form in swing swing login form example
How to reset a form in jQuery?
How to reset a form in jQuery?  Hi, I have a form where I am using jQuery. I want to reset the form. How I can reset the form grammatically?   Hi, You can use following code: $("#MyFomrName").reset(); Thanks
DOJO full form
DOJO full form  what is the full form of dojo
spring form validation
spring form validation  how can we validate a web form using spring, try to give an example of the form containing some fields and their validations,ASAP......   Please visit the following link: Spring form validation
Registration Form in HTML
Registration Form in HTML  User Registration Form in HTML - i wanted to design a user registration form in HTML. So, Can anyone please guide me or give me a peace of code to design a user registration form in HTML. Thanks
HTML form examples
HTML form examples  Hi, How to create a simple data entry form in HTML and use JavaScript to validate the same. Can anyone share html form examples code? Thanks   Hi, Please see the HTML form example page. Thanks
to creating a registration form
to creating a registration form  how to create a registration form
Form Tag library configuration
In this section, you will learn about Spring form tag library and its configuration
multiple submits, single form.
multiple submits, single form.  is it possible to use multiple submit buttons in a single form?   Thank you
Form Handling in Spring Framework
Form Handling in Spring Framework  I have created spring project.I created the form. When I entered the values to the form, the values should... the program the program is forwarding to another page according to form action
Ajax form submit
Ajax form submit  Hi, Provide me the example code of Ajax form submit. I want quick tutorial that will help me in writing form submit code in Ajax. Thanks   Hi, Read jQuery 'submit' form event tutorial. This tutorial
 

 

 

DMCA.com