473,698 Members | 1,817 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 1233
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
2316
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
2382
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
5188
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
1762
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
2665
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
2360
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
1221
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
3976
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
9021
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8892
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,...
0
8860
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7716
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
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
4365
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...
1
3043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1998
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.