Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Displaying the error data in Red Color

Posted on 2002-07-30
7
Medium Priority
?
162 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 200 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

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…
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…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Integration Management Part 2

971 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