Zach Dennis has posted a few ideas that I don't completely understand...



Some of my ideas are out there, but I have not once had to give up on any of them, and I've found ways for them all to work within their own boundaries, although it may take some serious thought and out-of-the-box type thinking.

A better explanation behind my suggestion would to have your web page with your genericField_validator function and the array(which is a4d created) and then the actual html code...

<html>

<script language="javascript">
function genericField_validator(obj,rule){
for( i=0 ; i<arRules.length ; i++ ){
v_rule = arRules[i].indexOf(rule);
if( v_rule>-1 ){v_rule=arRules[i];break}
}
v_check = v_rule;
x = v_check.indexOf("|");
v_rule = v_rule.substring(0,x-1);
v_check = v_check.substring(x+2);
x = v_check.indexOf("|");
v_check = v_check.substring(0,x-1);
switch (v_check){
case "==":
//--then provide validation here--//
alert("Validating a " + v_rule + " field to equals a specified format");


                break
}

}

arRules = new Array(); //a4d created
arRules[0] = "date | == | xx-xx-xxxx"; //a4d created
arRules[1] = "phone | == | xxx-xxx-xxx"; //a4d created
//etc...
</script>

<body><form>
<input type="text" name="strDate" rule="date" onBlur="genericField_validator(this,this.rule);">
<input type="text" name="textfield1">
</form></body></html>


...you can copy and paste that code and run it, just tab to the next field.

The script is partially working because I didn't fill in the actual validation part, but the idea is there. If you get what I am trying to do then let me know and I will give you a working script to mess around with, if you don't get what I am doing and you'd like to then let me know...and then if you don't get what I am doing and you think I am crazy, you can let me know that to.

Basically what is happening is Active4D will create an array in javascript where each element equals a set of rules/parameters like "date | == | xx-xx-xx". When an object would lose focus it would call the genericField_validator function and pass itself and it's rule as parameters. The function would simply check to see what rule it should be looking for. In our case it was looking for "date". Then it would parse out to see what criteria you were forcing("=="), which is meant to show that it must equals a following format. The last part(which i didn't do in the above script) would run through some validation code to see if the value of your field met the format of "xx-xx-xxxx". Your genericField_validator function can be in an external .js file, but I would suggest to create the array in the .a4d page being as it is dynamic content.

Let me know what you think,

Zach Dennis
Market Technologies Inc.



_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail




Reply via email to