0

Hi guys,

I have an ideea of doing 3 form validations from one file

The content of the file is

//detalii 1-categorie
var categorie  = new Validator("categorie");
categorie.addValidation("add_categorie","req","Va rugam sa va completati categoria");

//detalii 2-subcategorie
var subcategorie  = new Validator("subcategorie"); 
subcategorie.addValidation("add_subcategorie","req","Va rugam sa va completati subcategoria");

//detalii 3-continut
var continut  = new Validator("continut");
continut.addValidation("add_continut","req","Va rugam sa va completati continutul");

How could I load 1 if I'm on page 1 and 2 if I'm on page 2 and so on ... ?

Any ideas instead of doing 3 separate files ?

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by Taywin
0

I do not understand the question. :( Why are these scripts in separated file? Could you simply put them all in 1 file and then include it using src? The down side is that you would include other variable/data that will not be used in differen pages. Unless you pass a variable to specified which variable you want to be loaded...

//i.e.
var categorie = null
var subcategorie = null
var continut = null
function getValidator(validatorName) {
  if (validatorName=="categorie") {
    categorie = new Validator(validatorName)
    categori.add(...)
  }
  else if (validatorName=="subcategorie") {
    subcategorie = new Validator(validatorName)
    subcategori.add(...)
  }
  else if (validatorName=="continut") {
    continut = new Validator(validatorName)
    continut.add(...)
  }
}

But better yet, use the same variable name instead of 3 variables...

//i.e.
var categorie = null
function getValidator(validatorName) {
  categorie = new Validator(validatorName)
  if (validatorName=="categorie") {
    categori.add("add_categorie","req","Va rugam sa va completati categoria")
  }
  else if (validatorName=="subcategorie") {
    categori.add("add_subcategorie","req","Va rugam sa va completati subcategoria")
  }
  else if (validatorName=="continut") {
    categori.add("add_continut","req","Va rugam sa va completati continutul")
  }
}

Edited by Taywin

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.