473,320 Members | 1,839 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,320 software developers and data experts.

Page submitting issue ..............

dmjpro
2,476 2GB
here is my code ......


[HTML]<html>
<head>
<title>Simple Test</title>
<script language = javascript>
function test()
{
if(document.all.txt.value == '')
{
alert('Blank');
return false;
}
else return true;
}
</script>
</head>
<body>
<form onsubmit = test()>
<input name = txt>
<input type = submit value = "SUBMIT">
</form>
</body>
</html>
[/HTML]

i want to stop submitting page if the text field is left blank .......

how can i do it .....

any help is most welcome .......
Feb 28 '07 #1
6 1217
acoder
16,027 Expert Mod 8TB
Do not use document.all! It is IE-only.

Use document.getElementById instead, but you must give an id to your text box to use this.

To solve your problem, just add "return" before calling test().
Feb 28 '07 #2
dmjpro
2,476 2GB
it is not clear to me ........

plz explain in details .....
Mar 1 '07 #3
dmjpro
2,476 2GB
sorry i think i don't understand ur point of view ......

finally i managed to do that ....

here is my code .......


<input type = submit vlaue = "SUBMIT" onclick = "if(document.all.txt.value == ''){alert('Blank');return false;}">

it's lead me to new direciton of js event overriding ......

thanx , thanxxxxx a looootttttttttttttttttttttttttttt................. ...
Mar 1 '07 #4
acoder
16,027 Expert Mod 8TB
No, don't do that! I've modified your code below:
[HTML]<html>
<head>
<title>Simple Test</title>
<script language = javascript>
function test()
{
if(document.getElementById("txt").value == '')
{
alert('Blank');
return false;
}
else return true;
}
</script>
</head>
<body>
<form onsubmit = "return test();">
<input type=text name = txt id="txt">
<input type = submit value = "SUBMIT">
</form>
</body>
</html>
[/HTML]
Mar 1 '07 #5
dmjpro
2,476 2GB
is there any special difference between ur code and my code !!!!!!!!!!!!!!!!!!!!!!!!!!

i think it is easy to code ... nothing else ... am i right .........


lot of tahnx ......
Mar 1 '07 #6
acoder
16,027 Expert Mod 8TB
No, document.all works in IE and is not standard (even though Opera supports it I think). document.getElementById is the standard and works in all modern browsers.

You could also use the name of the form to get access to the text input.

When you have onsubmit, why use the onclick for the submit? What if the form is submitted in some other way, e.g. using the submit() method?
Mar 1 '07 #7

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

Similar topics

4
by: Mats | last post by:
Hi Maybee a little bit of topic, but is it possible to stay on the submitting page once you've clicked submit. This is to get processing done on page B when you submit on page A, and the page...
10
by: amit.purohit | last post by:
hi, I have a very strange problem on my login Page. the Page was working fine a few days back, but now does not generate post back events for controls. this login page uses form based...
8
by: John Scott | last post by:
I want to be able to put into the body of an email, the entire contents of a aspx page....with form fields filled out I know I could go through and get the values of all of the textboxes, radio...
5
by: Bill Cohagan | last post by:
I'm constructing an ASP app with a frameset on the home html page. From frame A I need to referesh the page in frame B when a button click occurs on a button in Frame A (server side event handler)....
8
by: -Karl | last post by:
Apparently, asp.net has a posting issue with refreshing. There seems to be several solutions to the issue but I was wondering if there is a final workaround for the issue? If so, can you please...
8
by: Ed Jay | last post by:
I want to use history.go() to navigate between my previously loaded pages. I'm looking for a way to trigger a function call when a page is accessed using history.go(). Is there an event generated?...
3
by: William Youngman | last post by:
I am on a team that is developing a proposal generation web application and we are using a custom base page (ProGenBase.cs) located in the app_code directory and all of the app's web pages inherit...
1
by: SachinBhargava | last post by:
Hi, I am faceing the problem while submitting the same page in ASP. When i am submitting the page, I am showing the java script alert message before closing the pop up window. My problem is, when...
1
by: CoolRajan | last post by:
Hi friends, I have four form pages in my application and all the pages contain different fields for entering values in that. In my first page I have one Continue button and on submitting it...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.