here is one form element.

<input value="-7" class="validate[required,custom[integer],min[5]] text-input" type="text" name="min" id="min" />

here is one more problem..
i wanto use my javascript varible value in above class "validate[required,custom[integer],min[5]]" here like use dynamic number where 5 is using how to do it?
Regards..

You cannot insert JavaScript right in the middle of a HTML element property, but you could access an element property to assign a value to the property. Once the element is created and added to the DOM, you then can use JavaScript to do the work. When I sad "created and added," it means when the page is loaded and/or ready. A simple way (but not very pretty) is to add JavaScript at the end of the body tag to run the modificaton. Or you could use onload in body tag to run your function once done.

<html>
<head>
  <style type="text/css">
  input.initclass {
    /* whatever initial style or leave it empty if none */
  }
  </style>
  <script type="text/javascript">
  var validate = ["class1", "class2", "class3", "class4"];
  function changeInputClasses() {
    var el = document.getElementById("min");
    // change the element property of class from "initclass" to "class4"
    if (el) { el.className = validate[3]; }
  }
  </script>
</head>

<body onload="changeInputClasses()">
 ...
 <input value="-7" class="initclass" type="text" name="min" id="min" />
 ...
 ...
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.