Support Forum Softcomplex logo
About Us  | Services  | Download  | Order  | Support  | |
| Search | Today's Posts | Stats | Board Rules | Not logged in [ Login | Register ]
go to bottom
Last active: Never

Printable Version | Subscribe | Add to Favourites   Post new thread
Author: Subject: alter 'm' type validation for greater than
matbeard
Junior Member

Posts: 4
Registered: 2/20/2006
Member Is Offline
posted on 5/9/2006 at 06:08 AM Reply With Quote
alter 'm' type validation for greater than


I'm tryin to add a new validation type that checks if a field is greater than another.

I've coped the code for checking for match, and changed it to this:
Code:
// check greater than
else if (this.a_fields[n_key]['g']) {
for (var n_key2 in this.a_fields)
if (n_key2 == this.a_fields[n_key]['g']) {
n_another = n_key2;
break;
}
if (n_another == null)
return this.f_alert(this.f_error(12, this.a_fields[n_key]));
if (this.a_fields[n_another]['v'] < this.a_fields[n_key]['v']) {
this.a_fields[n_key]['ml'] = this.a_fields[n_another]['l'];
this.a_fields[n_key].n_error = 13;
n_errors_count++;
}
}


I've also added the appropriate error messages to the array.

I'm using 'g':'other field' in the constructor.

However, it's not working. Is there anything else I need to do?

Thanks
View User's Profile View All Posts By User U2U Member
Hollstar
Member

Posts: 11
Registered: 4/4/2008
Location: Australia
Member Is Offline
posted on 6/10/2008 at 11:30 PM Reply With Quote

Hi Mate,

I had much the same problem and had to write my own addition to this script. In my case, I had two drop down or select boxes allowing the user to choose a min and max value from the list. Naturally, I wanted to ensure the minimum was less than or equal to its max.

I added the following lines to the JavaScript file:

Code:

// check less than or equal to
else if (this.a_fields[n_key]['<=']) {
for (var n_key2 in this.a_fields)
if (n_key2 == this.a_fields[n_key]['<=']) {
n_another = n_key2;
break;
}
// Debug:
//alert("n_another v: " + this.a_fields[n_another]['v'] + " n_key v: " + this.a_fields[n_key]['v']);
if (n_another == null)
return this.f_alert(this.f_error(6, this.a_fields[n_key]));
if (this.a_fields[n_key]['v'] > this.a_fields[n_another]['v']) {
this.a_fields[n_key]['ml'] = this.a_fields[n_another]['l'];
this.a_fields[n_key].n_error = 6;
n_errors_count++;
}
}


I also added this line to the a_messages array:
'The minimum for "%l%" must be less than or equal to its maximum'

This code works exactly the same way the password compare function does. Instead of using "m" however you use "<=" and then the field name you're comparing. You of course also need to add the other field you're comparing to the script just as you do in the password compare example.

Good Luck! :)
View User's Profile View All Posts By User U2U Member
Hollstar
Member

Posts: 11
Registered: 4/4/2008
Location: Australia
Member Is Offline
posted on 6/10/2008 at 11:32 PM Reply With Quote

If you enable the debug I put in place, then compare it to your code, you will see where you went wrong...
Its all perfect except for one little thing! :)
View User's Profile View All Posts By User U2U Member
Post new thread

Related Links:
Product Page Tigra Form Validator
Product Demonstrations Product Demos
Registration Form Validation
Login Form Validation
Free Download Free Download
Product Documentation Documentation
Documenation Page
Change Log
Validators Comparison Table
Support Forum Support Forum
 
Tigra Form Validator PRO
Product Demonstrations Product Demos
Registration Form Validation
Login Form Validation
Multiple Forms Validation
Product Documentation Documentation
Documenation Page
Change Log
Validators Comparison Table
Support Forum Technical Support
Support Forum
Customer Care System
Order Now ORDER NOW!
Add to Cart
View Cart
 

Go To Top


Powered by XMB 1.9.1 Nexus
Developed By Aventure Media & The XMB Group © 2002-2004