I want to slide some jquery into a piece of another programmers javascript code that I have to work worth. Can I do this? Look at the code for the ‘radio’.
function blank(field) {
if ((field.type == "text" || field.type == "textarea") && (field.value == " " || field.value == ""))
{
return true;
}
else if field.type = "radio"
{
$('input[type='radio', **name=passField.NameHere**]:checked').size() > 0);
}
}
so in the above I want to use jquery to see if anything in a radio group has been checked.
Example of radio code:
<input type="radio" name="2074" id="2074" value="Yes" class="valuetext>Yes
<input type="radio" name="2074" id="2074" value="No" class="valuetext>No
I want to pass the field.name which has already been captured in another function, into the jquery call. Is this possible? If so, how?
Below is the function that gathers the fields that need to be exampled:
var field = [], blankFields = [],
listText = [], listItem = [], fieldId = [], label = [];
function checkRequired(fieldList) {
for (var i = 0; i < fieldList.length; i++)
{
listText = fieldList[i];
listText = listText.substring(1, listText.length - 1);
listItem = listText.split("||");
fieldId = listItem[0];
label = listItem[1];
field = document.getElementById(fieldId);
if (visible(field) && blank(field)){
blankFields.push(label);
}
}
//return blankFields;
if (blankFields.length > 0) {
displayError(blankFields);
}
}
Any help would be appreciated.
Yes, it looks like
fieldis the actual DOM object, so:Note that you have several syntax errors in the code other than the obvious place you were calling out a placeholder. For instance:
You need parens around the condition, and
=should be==or===.Also note that I changed
'to"in a couple of places, because originally you had:…which ends the string just after
type=, since the string started with'and therefore ends with'.