|
-
May 22nd, 2003, 10:58 PM
#1
Thread Starter
Fanatic Member
JS, ASP: Best way to validate? easy [resolved]
Ok here is the plan:
PageA.asp has a form. On that form I have
txtUser
txtPassword
cmdSubmit
After hitting submit, user gets redirected to PageB.asp where the result (user data) is stored in a database.
Now, what is the best way to validate that the user has filled out all the fields.
Do I do it in PageB.asp or PageA.asp
I was thinking of embeding a simple JS function into
Code:
<FORM ACTION="JS FUNCTION HERE">
</FORM>
Is that possible? Is that a good way of doing it, or does it have something to do with the actual Submit button.
I'm also pretty sure I could check the values on PageB.asp, to see if they are blank and display an error... would that work?
Thanks a lot,
InVitro
Last edited by invitro; May 23rd, 2003 at 03:21 PM.
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
May 22nd, 2003, 11:53 PM
#2
This is what we use:
Code:
<script language="JavaScript">
function validate(obj) {
if (obj.Field.value == "") {
alert("Some message goes here");
obj.focus();
return false;
}
return true;
};
</script>
<form name="blah" method="post" action="somepage.asp" onsubmit="return validate(this);">
<input type="text" name="Field">
</form>
-
May 23rd, 2003, 03:35 AM
#3
Using Javascript like axion_sa provided is a good way to do a quick check and give the user timely feedback without having to wait for the form to be sent to the server and back.
But it is good practice to do the checks again on the server side like checks for single quotes (used to always catch me out with peoples names)
-
May 23rd, 2003, 03:20 PM
#4
Thread Starter
Fanatic Member
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
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
|