473,722 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

dmjpro
2,476 Top Contributor
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 1236
acoder
16,027 Recognized Expert Moderator MVP
Do not use document.all! It is IE-only.

Use document.getEle mentById 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 Top Contributor
it is not clear to me ........

plz explain in details .....
Mar 1 '07 #3
dmjpro
2,476 Top Contributor
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.al l.txt.value == ''){alert('Blan k');return false;}">

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

thanx , thanxxxxx a looootttttttttt ttttttttttttttt ttt............ ........
Mar 1 '07 #4
acoder
16,027 Recognized Expert Moderator MVP
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.get ElementById("tx t").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 Top Contributor
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 Recognized Expert Moderator MVP
No, document.all works in IE and is not standard (even though Opera supports it I think). document.getEle mentById 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
2317
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 should not change. Normally I use a response.redirect to the submitting page, but that can't be done in one case. Mats PS I've found that one solution is to send Response.Status = "204 No Response" but according to some information that won't work...
10
2389
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 authentication. Whenever the button is clicked, no event is raised, infact it doesnt even go to the page_load as well. Events are registered and there is no problem with the code because the same code is working fine on Windows XP machine. The machine...
8
1655
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 button lists, etc, and format the body of my email, but it would be very convenient if I could just have the email contain exactly what the page looks like because the page is quite large. I've tried to do a Page.RenderControl(htmlTextWriter);...
5
5191
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). To accomplish this I've included some client side script in the page being built in frame A such that whenever it is received by the browser it reloads frame B's page. The problem is that (sometimes) this sequence of events produces a dialog...
8
1765
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 inform me what I need to do? I'm using ASP.NET 2.0 beta
8
2668
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? Is there a method for detecting what page the user came from when a page is accessed using history.go()? -- Ed Jay (remove M to respond by email)
3
2362
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 from this custom page. Additionally I have a main menu tab control that is located in a master page and certain tabs are displayed dependant on the users authentication level. I am using boolean properties in the master page to control the visible...
1
1222
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 the alert come the ASP page turn to white. The data is successfully submitted but white page not looks good. I am using the Frameset for submitting the page. Thanks in advance...
1
3979
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 redirects to second page. In the second page I have two buttons namely Back and Continue. After entering values in the second form page if I click the Back button then I am able to get into the first page with all the values which I have entered previously...
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.