Solved

Validating a text field

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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