473,326 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Default button and validation of text arrays

Hello

I have a java server pages with a form on it that has number of text boxes, hidden texts and some other controls (images, etc).

I have two questions. Could you please help me ?

1. I would like to make one of the buttons on my form the default, so if user presses enter, this button is clicked. How do I do that?

2. The name of text boxes on the form are dynamic. So I need to have a javascript that checks the fields of my form according to their type and then gives message if it is empty. What property should I use to indicate the type of control?

Any tutorials, codes, etc. is extremely appreciated.

Regards
Helen
Feb 10 '08 #1
4 1161
gits
5,390 Expert Mod 4TB
hi ...

could you please post the code you have so far ... so that we may have something to work with?

kind regards
Feb 10 '08 #2
hi ...

could you please post the code you have so far ... so that we may have something to work with?

kind regards
Thank you for replying. Unfortunately, I donot have any code regarding these questions yet.

About my first question, I am not sure if this should be done in JavaScript or it should be done in JavaServer Pages?

And about the second question, I would like to write a loop that goes through different fields of document and if it is textbox, it will validate it. But I don't know what property and value shows that a control is a text box?

So if you could just give me some hints, I will write the code myself and in case of problems, I can post it again.

Thank you
Helen
Feb 10 '08 #3
gits
5,390 Expert Mod 4TB
1. have a look at the keypress events and you could call a javascript-function that submits the form ... have a look here for a start

2. you could simply use:

Expand|Select|Wrap|Line Numbers
  1. var textboxes = [];
  2. var input_nodes = document.getElementsByTagName('input');
  3.  
  4. for (var i = 0, node; node = input_nodes[i]; i++) {
  5.     if (node.type == 'text') {
  6.         // we could fill a list
  7.         textboxes.push(node);
  8.  
  9.         // or even call a validate-function
  10.         validate_func(node);
  11.     }
  12. }
kind regards
Feb 10 '08 #4
Many thanks for helping :)
Feb 11 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: techfuzz | last post by:
I scoured this group and others looking for the best way to disable a button after the first click to prevent multiple submissions, but never did find anything that worked like they said it would. ...
1
by: NancyASAP | last post by:
Thought I'd share this since it took me a long time to get it working. Thanks to a bunch of contributers in Google Groups who shared javascript, etc. The question was: How can I put a reset...
4
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are...
7
by: ujjc001 | last post by:
Hello, it a .net app, in my client javascript code I would like to find out what event caused the page to validate. No, setting a hidden this or that will not do. I just want to know what event...
2
by: winnie_us99 | last post by:
Hi All, I am trying to do validation on my text field before going to the next page to create a user. It doesn't look like the next button will fire any validation. Am I missing something? Can...
3
by: Remy | last post by:
Here is the situation: I have an ASP.NET 2.0 page with 2 panel. Each has a few textboxes and one DefaultButton. All textboxes have one or more Validator. Now everything works fine if I fill...
2
by: Pawel Pabich | last post by:
Hi, I have very simple code: <asp:TextBox ID="TextBox1" runat="server"/> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
4
by: Greg Scharlemann | last post by:
I'm trying to setup a dyamic dropdown list that displays a number of text fields based on the selected number in the dropdown. The problem I am running into is capturing the data already entered...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.