|
-
Jan 29th, 2002, 08:10 PM
#1
Thread Starter
Hyperactive Member
Default Button
Hi all,
I understand that if I put a submit button on a page, that button becomes the default button (ie, just press enter and the submit button activates)
However, if i want to do some validation before I submit the form, I use an input=button. However, when I do that, that button doesnt receive the focus automatically and the use has to manually click on it.
The Q is, how do i enable the default status of a button just like it were a submit button ?
Thanks.
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
-
Jan 29th, 2002, 08:32 PM
#2
HI SoftwareMaker,
You dont really have to use input button, you can use submit button to do your validation.
this is how i do my validation on most forms
Code:
<html>
<head>
<script>
function validate()
{
if (some condition)
{
alert(msg);
return false;
}
if (another condition)
{
alert (msg);
return false;
return true;
//if the functions returns true then the form will
//be submited otherwise the form wont be submited
}
</script>
<body>
<form action="submit.asp" onsubmit="return validate()">
</form>
</body>
</html>
Hope this helps
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jan 29th, 2002, 09:02 PM
#3
Lively Member
Normally I used this codes to do the form focus and validation as well:
Code:
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--
Sub window_onload
Login.txtLogin.focus()
End Sub
Sub submit1_onclick
if len(login.txtPassword.value) < 6 then
Login.txtPassword.value = ""
msgbox "Password too short!"
exit sub
end if
login.submit()
End Sub
-->
</SCRIPT>
-
Jan 29th, 2002, 09:05 PM
#4
Thread Starter
Hyperactive Member
Thanks guys for your tips.
Thanks Daniel...so you are saying that once the function return false, the form wont get submitted ?
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
-
Jan 29th, 2002, 09:35 PM
#5
Thread Starter
Hyperactive Member
Hi daniel,
I am sorry BUT it seems to me that the input type=submit doesnt have a onsubmit event, so how now ?
Thanks
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
-
Jan 29th, 2002, 09:41 PM
#6
Thread Starter
Hyperactive Member
OOppps...Sorry my fault,
I put on my glasses and actually saw that it is a form event not an input event. Sorry...
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|