Solved

Displaying the error data in Red Color

Posted on 2002-07-30
7
154 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

by:dash420
Comment Utility
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
Comment Utility
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
Comment Utility
Hi ....

did this help ???

K'Rgds
Anand
0
 

Expert Comment

by:SpideyMod
Comment Utility
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
website file permissions 4 52
excpetion with multiple catch 11 104
URL redirect 4 47
IPA - can it be run on a web server? 3 116
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…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

13 Experts available now in Live!

Get 1:1 Help Now