Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SUBMIT PROBLEM

Status
Not open for further replies.

vbkris

Programmer
Jan 20, 2003
5,994
IN
did u know that giving the validation of a form in the submit button will not work if the form has only one textfield?

try creating a form and a single textfield, write the script for the textfield validation and put it in the submit button.

give focus to the textfield and hit enter key

validation will not happen (atleast in IE)

Exception:
to be on the safe side do all form validations in the onsubmit event of the form.

<form ..... onsubmit=&quot;return validate();&quot;>
 
I never use an INPUT TYPE=SUBMIT button in my forms. I always write a button like this...

<script>
function subForm(){
//verify form items
if (verified){
document.myForm.action = &quot;handler.asp&quot;
document.myForm.method = &quot;post&quot;
document.myForm.submit()
}
}

<form name=myForm>
...
...
<input type=button onClick=&quot;subForm()&quot; value=&quot;Submit&quot;>
</form> Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
 
mwolf00 - Talk about taking out anyone that doesn't use javascript. You can easily do it with a onsubmit, so there is no reason to exclude the people that don't use javascript. If you do insist on doing it like that, at least do something like this:

<input type=submit onclick=&quot;subForm(); return false;&quot;>

Then it will only run the function for people with javascript and it will still work without javascript.
 
Adam,

I guess it depends on the form and what you're trying to do with it. If I were concerned about ppl w/o javascript, I'd do server-side validation. I usually work on extranets and I hadn't thought about ppl who don't allow javascript. Any idea on a percentage of how many people don't allow javascript? Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
 
Wow! 10% with javascript disabled! Who knew! Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
 
Yeah, it is kind of surprising. The only thing about that is I think the majority of people that have it turned off are either at a school that turns it off or part of a large corporation that turns it off. I doubt that there are very many people that just turn it off for the heck of it... :)
 
(shhh... actually, I do. 95% of the JavaScript out there is unnecessary and/or a pain-it-the-fanny. So one of my browsers is set to query before running JS -- every time. I usually just hit &quot;no.&quot; Another browser is set to accept JS, but only certain things [it won't open new windows, but it'll do mouseovers, for example]. I run it if i want to run a site that has JavaScript I need, such as an order site, or my online calculator.

Don't get me wrong, I luuuuv JavaScript and the ability to do pretty significant programming for the client-side. But with great power comes great irresponsibility... [smile])

Subversively,
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Originally posted by EdwardMartinIII
But with great power comes great irresponsibility...

Are you suggesting that people abuse javascript? I mean, there are some people that have the background of the page flash, no right-clicks, or other such annoyances, but for the most part, people only use it for useful stuff(rollovers, etc). Pretty much all it does is make it look better... I guess I don't get turning it off since sites then wouldn't look like what they are designed to look like. Doesn't that bother you?? ;)
 
Originally posted by AdamBrill
Are you suggesting that people abuse javascript?

You are so lucky I didn't have a mouthful of coffee or I would once again have to ask SysAdmin to replace my keyboard... [lol]

Cheers,
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
lol ;) You really think that that many people abuse it?? I hardly ever see that kind of stuff... Of course, that could be because if I see that the site is geoCities(or some other cheap, abused server), I just don't go there. :) About 90% of the people on there abuse it...
 
Heh. Like I wrote, 95% of the JavaScript out there is unnecessary or a pain. (not the people)

There are some good reasons to have client-based computing going on, such as form validation, calculations, etc. But the rest just simply isn't necessary. We don't need JavaScript to make our pages look better. If our pages look like crap, spray-painting them with mouseovers isn't going to hide that. Designing good pages and good sites that are easy to understand and use is a better step.

We really don't NEED pop-up menus, do we? I mean, what's wrong with, well, a narrow little menu along on edge or the other? Or along the top? Nothing at all.

And, really, there's a huge percentage of JavaScript &quot;use&quot; (&quot;how can I disable the browser task bar?&quot;, for example)that is just an attempt to make a website act like a Windows application. If I wanted a Windows application, I'd write one, and then upload the executable to a website. If I wanted to cater to the nine people out there with a Mac, I'd build a Mac app and upload it to my site as well, again, as a downloadable (okay, I'd upload, say, fifteen copies, in case more people buy Macs).

JavaScript is probably a lot like beer -- rarely necessary, but consumed and sprayed all over indiscriminately. [lol]

I'm not a total Luddite, though. I see JavaScript as having a lot of very interesting applications. In fact, I regularly engage in &quot;spirited discussions&quot; with a friend of mine who feels that JavaScript is at best a toy. That was what got our wheels rolling in the direction of building complex calculators, word processors, and graphing applications entirely out of JavaScript.

But I'm pretty firmly in the same camp as the fellas at

Cheers,
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
I would have to disagree, but that's ok. ;) I would agree about the windows application part, though. If people want the power of a windows application, they should just make windows applications. :) People don't seem to get that it is only a browser... ;)
 
Okay, you caught me. There's got to be at least twenty people with Macs.

And I'm sure there's probably lots of necessary JavaScript out there. But I'll betcha there's still 9.5 times as much JS that isn't necessary...[smile]

Cheers,
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
I think if people want to write an application for many platform they should write Java applications.

If people want a web application they should use Javascript intensively (it can have some great benefits like speeding up the pages or adding functionalities to the interface like calendars, server calls without reloading the whole page).

If people want to create a web site they should use Javascript sparingly and make sure that usability and simplicity are not disregarded. The most important thing to a web site is content. Without good content what is the use of spending countless hours for a container?

One of my favorite web interface out there is a news site ( Though there are a few things that could be more usable it shows that using Javascript can really enhance a site. Gary Haran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top