Solved

Validating a text field

Posted on 2000-05-08
5
122 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now