•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 374,612 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,400 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 577 | Replies: 1
![]() |
•
•
Join Date: Mar 2008
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
hi there could any one solve this problem for me plzz.....
In my site iam generating multiple textfields and i need to wite validation for that
In my site iam generating multiple textfields and i need to wite validation for that
function valid(){
for(var i=0;i<4;i++){
if(document.getElementById('d'+i).value == ""){
alert("not empty");
return false;
}
return true;
}
}<form name="f1"> <input name="cc1" id="d1" type="text" value="0" /> <input name="cc2" id="d2" type="text" value="0" /> <input name="cc3" id="d3" type="text" value="0" /> <input name="cc4" id="d4" type="text" value="0" /> <input name="submit" type="submit" onclick="return valid()" /> </form>
The following code is checking if the text boxes that are named "text" have values
and if thats correct the code returns true and submit the form, all it does is checking if one of the text boxes have values, but if u want all the text boxes to have values u have to validate each one of them.
// "Text" elements are textboxes
and if thats correct the code returns true and submit the form, all it does is checking if one of the text boxes have values, but if u want all the text boxes to have values u have to validate each one of them.
// "Text" elements are textboxes
var validText = false;
for (var i = 0; i<document.MyForm.elements.length; i++) {
if (document.MyForm.elements[i].name = "Text" (
if (document.MyForm.elements[i].value != "") {
validText = true;
}
}
}
return validText; Some people get so rich they lose all respect for humanity. That's how rich I want to be.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Monthly calender for javascript
- Next Thread: Login window?


Linear Mode