Hi I am using jquery 1.4.2 and jquery validate 1.7(http://bassistance.de/jquery-plugins/jquery-plugin-validation/)
Say I have this example that I just grabbed off some random site(http://www.webreference.com/programming/javascript/jquery/form_validation/)
8 <script type="text/javascript">
9 $(document).ready(function() {
10 $("#form1").validate({
11 rules: {
12 name: "required",// simple rule, converted to {required:true}
13 email: {// compound rule
14 required: true,
15 email: true
16 },
17 url: {
18 url: true
19 },
20 comment: {
21 required: true
22 }
23 },
24 messages: {
25 comment: "Please enter a comment."
26 }
27 });
28 });
29 </script>
now is it possible to do something like this
10 $("#form1").validate({
var NameHolder = "name"
11 rules: {
12 NameHolder: "required",// simple rule, converted to {required:true}
13 email: {// compound rule
14 required: true,
15 email: true
So basically I want to make sort of a global variable to hold theses rule names( what correspond to the names on that html control).
My concern is the names of html controls can change and it kinda sucks that I will have to go around and change it in many places of my code to make it work again.
So basically I am wondering is there away to make a global variable to store this name. So if I need to change the name I only have to change it in one spot in my javascript file sort of the way stopping magic numbers ?