keyman2007
Technical User
Hi, all...
I am trying to do something that seems pretty elementary, but I am stumped.
I want to do the same JS edit on a number of form fields, so rather than code the edit in 10 locations, I wanted to make a function that takes the form-field-name as a parameter (qq) to do the edit. An idea like the following, except the code doesn't work.
(I know there are other ways to do these edits, but I am asking how to replace the segment in the document field-name with a variable):
==================================
test("lastname") // call the function, passing field-name
if (pp == 1) {
alert("No periods allowed in this field")
return false
}
test("firsname") //call the function, passing field-name
if (pp == 1) {
alert("No periods allowed in this field")
return false
}
function test(qq) {
var pp = 0
for (var i=0; i <= document.idform.qq.value.length; i++) {
if (document.idform.qq.value.charAt(i) == "."
{
pp=1;
}
}
}
[/color red]
==================================
I am trying to do something that seems pretty elementary, but I am stumped.
I want to do the same JS edit on a number of form fields, so rather than code the edit in 10 locations, I wanted to make a function that takes the form-field-name as a parameter (qq) to do the edit. An idea like the following, except the code doesn't work.
(I know there are other ways to do these edits, but I am asking how to replace the segment in the document field-name with a variable):
==================================
test("lastname") // call the function, passing field-name
if (pp == 1) {
alert("No periods allowed in this field")
return false
}
test("firsname") //call the function, passing field-name
if (pp == 1) {
alert("No periods allowed in this field")
return false
}
function test(qq) {
var pp = 0
for (var i=0; i <= document.idform.qq.value.length; i++) {
if (document.idform.qq.value.charAt(i) == "."
{
pp=1;
}
}
}
[/color red]
==================================