User Name Password Register
DaniWeb IT Discussion Community
All
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 375,246 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,147 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: 2325 | Replies: 5
Reply
Join Date: Jul 2006
Posts: 173
Reputation: vssp is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 4
vssp vssp is offline Offline
Junior Poster

Solution Javascript alert not working

  #1  
Jan 23rd, 2007
Hai friends

I am using array "name " field for example

<input name="prod_image[]" type="file" class="Textfield" id="prod_image[]"/> *</td>

When I try to validate the text box NULL or not using Javascript ,I unable to validate

Please any one advice me
__________________
Thanks
VSSP
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Posts: 138
Reputation: php_daemon is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
php_daemon php_daemon is offline Offline
Junior Poster

Re: Javascript alert not working

  #2  
Jan 23rd, 2007
What's the code for validation? Can you post it here?
Reply With Quote  
Join Date: Jul 2006
Posts: 173
Reputation: vssp is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 4
vssp vssp is offline Offline
Junior Poster

Re: Javascript alert not working

  #3  
Jan 23rd, 2007
hi R u know about the solution this issue !!!!!!!!!!!!
Thanks
VSSP
Reply With Quote  
Join Date: Sep 2005
Posts: 611
Reputation: digital-ether will become famous soon enough digital-ether will become famous soon enough 
Rep Power: 5
Solved Threads: 38
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Practically a Master Poster

Help Re: Javascript alert not working

  #4  
Jan 23rd, 2007
Originally Posted by vssp View Post
Hai friends

I am using array "name " field for example

<input name="prod_image[]" type="file" class="Textfield" id="prod_image[]"/> *</td>

When I try to validate the text box NULL or not using Javascript ,I unable to validate

Please any one advice me



[HTML]

var value = document.getElementById('prod_image[]').value;

[/HTML]

That should get you the value of the input of id "prod_image[]".

The only problem that I can think of is if you have more than one id of "prod_image[]".

Example:

[HTML]<input name="prod_image[]" type="file" class="Textfield" id="prod_image[]"/>
<input name="prod_image[]" type="file" class="Textfield" id="prod_image[]"/>
<input name="prod_image[]" type="file" class="Textfield" id="prod_image[]"/>[/HTML]

Then document.getElementById('prod_image[]') will only return the first input element.

If you have multiple inputs like above you can iterate through them using the DOM method, getElementsByTagName().

Eg:

[HTML]var inputs = document.getElementsByTagName('input');

for (var i = 0; i < inputs.length; i++) {

if (inputs[i].type == 'file') { // check if this is a file
// do your validation here...

}

}[/HTML]

The problem with method is that you will get all input elements in the document via document.getElementsByTagName('input'); while all you want are the input elements in the form you are validating.
To get elements only in the form you will use:

[HTML]document.forms['form_name'].getElementsByTagName('input');[/HTML]

where 'form_name' is the name of your form.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Join Date: Jul 2006
Posts: 173
Reputation: vssp is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 4
vssp vssp is offline Offline
Junior Poster

Re: Javascript alert not working

  #5  
Jan 23rd, 2007
Thanks digital-ether Its working

Thanks for your replay
Thanks
VSSP
Reply With Quote  
Join Date: Sep 2005
Posts: 611
Reputation: digital-ether will become famous soon enough digital-ether will become famous soon enough 
Rep Power: 5
Solved Threads: 38
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Practically a Master Poster

Re: Javascript alert not working

  #6  
Jan 24th, 2007
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 4:48 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC