Solved

Validating a text field

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

Superior storage. Superior surveillance.

WD Purple drives are built for 24/7, always-on, high-definition security systems. With support for up to 8 hard drives and 32 cameras, WD Purple drives are optimized for surveillance.

Question has a verified solution.

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

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

948 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

20 Experts available now in Live!

Get 1:1 Help Now