generalised form validation functioins

Results 1 to 2 of 2

Thread: generalised form validation functioins

  1. #1 Guest

    Default generalised form validation functioins

    hai <BR>Can I write a JS function which can handle my form validations as a .js file. i want to pass the form name as one parameter and elements in that form as an array as the second parameter. my idea is regardless of the form, for the validations, i will call this general function where i will pass the form name and elements array. In that array i will pass the validation message also with respect to the controls... <BR><BR>is it possible of is any other better method is for doing something like this. My requirement is i don;t want to write the validation function in each and every page. <BR><BR>pl. help by giving an answer or suggesting better solutins ( i have posted the same in JScript forum also but no reply so far)<BR><BR>thanks in advance <BR>

  2. #2
    Join Date
    Dec 1969

    Default Sure, why not?

    Just use a NAMING CONVENTION when naming your form fields...where the name of the field tells the validation code what to do!<BR><BR>So if the name is something like Name="CG1_FoodsLiked" that would be interpreted by the validation code to mean "This field is a "C"heckbox in a "G"roup of checkboxes where at least "1" of the boxes must be checked. "CG0" might mean none have to be checked. "CG1-4" might mean 1 through 4 must be checked (0 or more than 4 being an error. Etc., etc. You just work out your own "code" and then do a big switch in the JS code based on the first letter of the code and sub-switches based on second letter, etc., etc.<BR><BR>"DN" might mean it must be a valid date, No time. "DT" with time. choose what you prefer.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts