Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

Displaying the error data in Red Color

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
praveenkeerthi
Asked:
praveenkeerthi
  • 2
  • 2
  • 2
  • +1
1 Solution
 
anandkpCommented:
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
 
CFXPERTCommented:
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
 
dash420Commented:
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
[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

 
dash420Commented:
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
 
CFXPERTCommented:
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
 
anandkpCommented:
Hi ....

did this help ???

K'Rgds
Anand
0
 
SpideyModCommented:
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now