Saturday, March 24, 2012

validation in a datalist

Howzit,

I've created a datalist with textboxes for data capture and I want to validate the information entered without a postback. My problem is that the formula is the sum of the first 4 textboxes must equal the value of the 5 textbox. If the values are not equal display the difference in a label on the same row.

I can't get the Custom Validator only checks the value of the textbox it's linked to.

Any suggestions?Textbox1=2
Textbox2=4
Textbox3=5
Textbox4=1, Total = 12.

and Textbox5=12

//JavaScript

Function jsSum() {
txtTotal.value=ParseFloat(Textbox1.value)+ParseFloat(Textbox2.value)+ParseFloat(Textbox3.value)+ParseFloat(Textbox4.value)
}

// End Javascript

we got -- > txtTotal=12

we got --> t Textbox5=12

- Compare using <asp: CompareValidator > or <asp:CustomValidator>
- hidden the txtTotal so the user can not see it..
Cint(txtTotal.text) = Cint(Textbox5.text) -- > The Result is TRUE.

Good Luck :)

No comments:

Post a Comment