Okay, so I've searched and searched. I've Googled until I can't Google anymore. I've tried code that was supposed to work and didn't. All I'm trying to do is validate a that a file input HTML control has text in it before the user can click to add another file. It's a cascading input control using JavaScript that I created following a video tutorial on www.asp.net. The guy didn't put any validation on the control so you can add more controls to your heart's content even if they're blank.
Here's my JS:
It works great. I'm just trying to validate that the input controls have something in them before I add another input control via JS.Code:<script type="text/javascript"> function AddFileUploadBox() { if (!document.getElementById || !document.createElement) return false; var UploadArea = document.getElementById("SuppFileUpload"); if (!UploadArea) return; var Paragraph = document.createElement("p"); UploadArea.appendChild(Paragraph); var NewUploadBox = document.createElement("input"); NewUploadBox.type = "file"; NewUploadBox.size = "100"; if (!AddFileUploadBox.lastAssignedId) AddFileUploadBox.lastAssignedId = 100; NewUploadBox.setAttribute("id", "Supp_FileUpload" + AddFileUploadBox.lastAssignedId); NewUploadBox.setAttribute("name", "Supp_FileUpload" + AddFileUploadBox.lastAssignedId); UploadArea.appendChild(NewUploadBox); AddFileUploadBox.lastAssignedId++; } </script>
If I do an alert based on the control, it just says "[object]" in the message box. Basically, regardless of what text is in the input box, it always thinks it's null.



Reply With Quote

Bookmarks