Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Validating a text field

Posted on 2000-05-08
5
Medium Priority
?
133 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 30 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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

722 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