Solved

Displaying the error data in Red Color

Posted on 2002-07-30
7
157 Views
Last Modified: 2013-12-24
On submitting the a form i need to check for the validation and post the data in red color before submiting to the server. Everything be done under same form. Redirecting the same pages for posting the errors.
waiting for your reply..

0
Comment
Question by:praveenkeerthi
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 17

Accepted Solution

by:
anandkp earned 50 total points
ID: 7188021
Hi,

This is simple

1. create a list called javaerror & initialise it to ""

2. U could chk for validation & the fields that violate the validations .. could be traped in a list [javaerror] when the form is submitted back to itself.

so now when displaying the form, the javaerror has the fields that need to be displayed in red
so just chk for listcontainsnocase - & mark the specific one in red.

there ur done

let me know

K'Rgds
Anand
0
 
LVL 5

Expert Comment

by:CFXPERT
ID: 7188044
Sounds like  a good approach to me.  Or You could always use Javascript to do this and not even worry about posting the form to itself.  Just have some hidden remarks next to each field and when the user hits submit the javascript validates the fields then makes visible the hidden remarks next to each field that is left blank.

Rather simple method I've used alot in the past and it works really cool.

I could give you some source code samples if you like.
0
 
LVL 6

Expert Comment

by:dash420
ID: 7188287
Do the java script validation and set hidden variable for each controls(mandatory contols of course). if any one fails in the validation. set the coressponding hidden variable and redirected to same page.

<script language="javascripts">
   function fnvalidate(){
     var bolfails = false
     if(document.formname.txtname.value == ""){
        document.formname.hdnname.value = 1
        bolfails = true
     }
     do same for other mandatory feilds
     ....
     ...

     if(bolfail == true){
        submited to same page
     }
     else{  
       submited to save page
     }

</script>

in the form just check

<cfif isDefined("form.hdnname")>
   <td><font color="red">Name</font></td>
<cfelse>
   <td>Name</td>
</cfif>
do same for the rest of the mandatory fields. of course for each mandatory feilds one separate hidden variable.



0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 6

Expert Comment

by:dash420
ID: 7188291
do following edit to the code.


<cfif isDefined("form.hdnname") and form.hdnname is "1">
  <td><font color="red">Name</font></td>
<cfelse>
  <td>Name</td>
</cfif>
0
 
LVL 5

Expert Comment

by:CFXPERT
ID: 7192347
FormPage.cfm

<script language="javascript">
function validateFields(){
if(main.field1.value == ""){
document.all.fld1.style.visibility = "visible"
}
document.main.submit();
}
</script>

<form name="main" action="" method="post">
<table>
<tr>
    <td><input type="text" name="field1"></td>
    <td id="fld1" style="color:red;visibility:hidden">Please enter your first name.</td>
</tr>
<tr>
    <td><input type="button" name="but1" value="Submit" onClick="validateFields()"></td>
</tr>
</table>

this is a very simple example of how to achieve what you need withour having to post the form to itself.  You can very easily build off of this method and it's very effective.

KWK
0
 
LVL 17

Expert Comment

by:anandkp
ID: 7219587
Hi ....

did this help ???

K'Rgds
Anand
0
 

Expert Comment

by:SpideyMod
ID: 8300827
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Website being blocked? 3 129
Finding an Azure real-time monitoring dashboard 2 74
Web server settings related to keepalive 1 126
listing all functions in JavaScript 19 216
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…
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…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 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