Solved

Validating a text field

Posted on 2000-05-08
5
130 Views
Last Modified: 2013-12-24
I am trying to include validation that will give an error message if a userid field is left blank...does anyone know why this code is not working?????



<font face="Arial, Helvetica, sans-serif" size="2"><b><i>Returning users enter the user id that you were given upon leaving the test then click the button below</i></b></font>
                                                      
                                                      <form name="mbti" action="http://nextpage.com/bl/blevel.signinverify" method="post" target="other">
                                                      <input type= "hidden" name="login" value="AAAAAAA">
                                                      <input type="hidden" name="password" value="BBBBBBB">
                                                    <input type="text" name="userid" ><br>
                                                      <input type="hidden" name="userid_required" value="You must enter a userid in order to log on as a returning user." >
                                          
                                                      <input type="submit" value="re-enter" >
                                                      
                                                      
                                                      </form>
0
Comment
Question by:the_kid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 2

Expert Comment

by:paulkd
ID: 2790245
How about awarding some points or adding comments to previous questions before adding more (10 point) questions?
0
 
LVL 5

Expert Comment

by:nathans
ID: 2790325
If you want help with ColdFusion go to

www.nsnd.com

0
 
LVL 5

Accepted Solution

by:
nathans earned 10 total points
ID: 2790561
This is the way I would do Form Validation.  This is better so that the user never leaves the page with out the form being filled out correctly.  Well at least they will have something in the form.

For more ColdFusion Tips or JavaScript visit:
ColdFusion Tips Plus
www.nsnd.com

==================================
<script language="JavaScript">
    <!-- hide contents from old browsers
    function checkform(form)
    {
     var errorstring;
     errorstring = "";
//    
     if (form.userid.value.length == 0)  { errorstring = errorstring + "User ID can not be blank.\n"; }
     if (form.password.value.length == 0)  { errorstring = errorstring + "Password can not be blank.\n"; }
     if (errorstring.length == 0)
       {
        //form.submit();
        return true;
       }
     else
     {
      errorstring = "Data must be entered in the following fields:\n\n" + errorstring;
      alert(errorstring);
      errorstring="";
        return false;
     }
    }
    //-->
   </script>




<form name="mbti" action="http://nextpage.com/bl/blevel.signinverify" method="post" onsubmit="return checkform(this)" target="other">
<table align="center" border="1" bordercolor="006699" cellpadding="0" cellspacing="0" width="450">
<tr>
      <td>
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
      <td align="left" bgcolor="dddddd" colspan="2">Login</td>
</tr>
<tr>
      <td>UserID:
</td>
      <td><input type="text" name="userid" ></td>
</tr>
<tr>
      <td>Password:</td>
      <td><input type="text" name="password" value=""></td>
</tr>
<tr>
      <td align="center" colspan="2"><input type="submit" value=" OK " > </td>
</tr>



</table>
</td>
</tr>
</table>


</form>

0
 

Author Comment

by:the_kid
ID: 2792455
Thanks for your answer. What I was looking for was more along the lines of what I have below though.


<cfform name="mbti" action="http://www.nextpage.com/blevel.signinverify" method="post" target="other">
                                                      <input type= "hidden" name="login" value="AAAAAAA">
                                                      <input type="hidden" name="password" value="BBBBBBB">
                                                    <cfinput type="text" name="userid" required="yes" message="You must enter a userid in order to log on as a returning user." ><br>
                                                      <input type="submit" value="re-enter" >
                                                      
                                                      
                                                      </cfform>
0
 
LVL 5

Expert Comment

by:nathans
ID: 2792660
Why are you passing these fields hidden???

Just wondered why?

By the way so that you can get better answers and have more points for questions...

1. You either pay for more points.. Ouch.

2. Wait and ask questions when you have more points...

Did you check out my website?  It has coldfusion help and it is growing.
0

Featured Post

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

734 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