Solved

validation checking on text boxes

Posted on 2003-11-03
5
203 Views
Last Modified: 2010-04-09
I hv a simple feedback form page where i want to validate empty text boxes
for eg: email text box with comment area box
when user donot insert email information and comment it should provide alert mes like "Please insert ......."
then only submit form should proceed
please suggest me
Regards
0
Comment
Question by:happyprogramming
  • 3
5 Comments
 
LVL 5

Expert Comment

by:ho_alan
ID: 9676743
<form name=fm1 onsubmit="check()">
<input type=text name=email>
<input type=text name=comment>
</form>

<script>
function check()
{
     valid=true;
    fmSize=document.fm1.length;
    for i=0;i<fmSize;i++
       if(document.fm1.elements[i].value=""){
           alert("please insert : " +document.fm1.elements[i].name)
       valid=false;
      }
   return  valid;
}
</script>
0
 

Author Comment

by:happyprogramming
ID: 9676781
This is my form page where i want to make sure user has put the valuyes

<html>
    <head>
          <title>User Feedback-From</title>
    </head>

    <body bgcolor="white" text="black" background=" "><center><font face=Courier New>

    <div align="center"><img src="reallogo.bmp" align="center" alt="LOGO"></div>
    </br>
    <center><font face="Verdana"><h2>User Feedback-Comment Form</h2>
<div align="center">
     </br>

<form method=post action="processfeedback.php">
   Your name: <br />
     <input type=text name="name" size=40><br />
   Your email address <br />
     <input type=text name="email" size=40><br />
<font size='1' color='blue'>*Please provide correct e-mail id to get reply.</font></br></br>
   <b>Your feedback:<br />
     <textarea name="feedback" rows=10 cols=70>
     </textarea><br />
     <input type=submit value="Submit  ">
     <input type=reset value="Clear All">
</form>
     </body>
0
 
LVL 5

Expert Comment

by:ho_alan
ID: 9676798
this function is general checking function
it should work in your  case

<form method=post action="processfeedback.php" onsubmit="check();">

0
 
LVL 5

Expert Comment

by:ho_alan
ID: 9676967
<form name=fm1 method=post action="processfeedback.php" onsubmit="check();">
0
 
LVL 2

Accepted Solution

by:
Netwing earned 40 total points
ID: 9677029
this should work:


<html>
    <head>
          <title>User Feedback-From</title>
             
              <script type="text/javascript">
<!--
function validateForm(objForm){
     var bValid=true;
     for (var i=0; i< objForm.elements.length && bValid;i++){
          if(objForm.elements[i].type.indexOf('select')!=-1){
                if(!(objForm.elements[i].value)){
                   bValid=false;
                    alert("Please insert ......");
                }
           }else{
               if(!objForm.elements[i].value){
                  bValid=false;
                  alert("Please insert ......");
               }
           }
   }
return bValid;
}

-->
</script>
             
             
    </head>

    <body bgcolor="white" text="black" background=" "><center><font face=Courier New>
<form method=post action="#" onSubmit="return validateForm(this)">
  <p>Your name:
    <input type=text name="name" size=40>
    <br>
    Your email address
    <input type=text name="email" size=40>
  </p>
  <p><font size='1' color='blue'>*Please provide correct e-mail id to get reply.</font>
    <br>
    Your feedback: <br>
    <textarea name="feedback" cols="50" rows="5"></textarea>
    <br>
    <input type=submit value="Submit  ">
    <input type=reset value="Clear All">
  </p>
</form>
</body>
</html>
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create tabs to show divs 9 35
Html Table Looping (part 2) 5 28
Selected in an option list 13 21
Send form to asp server side 6 14
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question