If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Javascript Validation In Asp Forms

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-21-04, 06:14
Mini Nair Mini Nair is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
Question Javascript Validation In Asp Forms

hi,

i have one problem with asp and javascripting..again....i have a form designed in which user has to enter values....out of these some values have to be entered compulsarily...and there is no guarantee that he will come to that text box..bcoz rest are selections which he may prefer doing using mouse.......so on blur event does not work...and then if he gets on to submit button then even if the user has not entered necessary values the page moves on to the next page.........so do i have any method using which i can mandate the user to enter the values as well as i also take care that the page does not get submitted ????????

also another problem is that everytime window.open method opens up a new window.....can u please tell me how to do this where it opens in the same window everytime.....

please help me out.......thanx in advance.....

mini
Reply With Quote
  #2 (permalink)  
Old 05-21-04, 11:49
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
You can do the validation two ways. Through JavaScript or through ASP. The problem with JavaScript is that someone can turn it off. ASP they cannot. Through JavaScript, you put an onSubmit() handler in the <form> tag. When your form is submit, onSubmit is caught and your code executed. Returning a true or false to the onSubmit will either stop the submit, or allow it to continue:

<form name="myform" action="mypage.asp" method="post" onSubmit="return checkForm();">

Now you need to create a function to check your values:

Code:
<script language="javascript">
function checkForm(){
    // Check the form values here to make sure they meet your criteria

    // If the fields pass do:
    return true;

    // If the fields fail do:
    return false;
}
</script>
This will return true or false back to the first return statement which returns true or false back to the onSubmit, telling the form to go or not.

Now, you can also do this in ASP, and just check the values after the submit. If the values fail, you redisplay the form with the values they typed in and mark the field that failed the test.

As for popup windows, it's the window name attribute of the window.open function.
Code:
window.open('mypage1.asp', 'myWindow', '');
window.open('mypage2.asp', 'myWindow', '');
window.open('mypage3.asp', 'myWindow', '');
Now all three pages should load in the same window.
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On