Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 16th, 2004, 04:45 PM
Authorized User
 
Join Date: Sep 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with Form Validation

i am validating a form . I have client side java script to validate fields. ONe field on form is non-editable
and i get the value of this non editable from a stored procedure and put it into the form. I need to validate a text box on this
same form against this non editable field. The problem is that I have to compare this text box field(client side)
to a server side value. When I insert code like this if (Frmcontactnewfcs.Txtreleasemailto.value != '<%("Contractors")%>')
in the javascript it doesn't take it. THe java script doesnt recognize this is a server side value. how do i do this? thanks
for any help.
 
Old September 16th, 2004, 05:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

can you post some more of your ASP code so that we can assist you ?
 
Old September 16th, 2004, 05:42 PM
Authorized User
 
Join Date: Sep 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok i will explain it in detail since the code is big so its hard to paste here . but i will paste whatever i can. thanks!

there is form which gets one of the form values from the store procedures like this.this field is uneditable.

<form id="Frmcontactnewfcs" style="MARGIN: 0px" onsubmit="return validateform();" method =post>

<th>
                                    Future Contractors</th>
                                <td class="data" noWrap input id = "futurecontractors" name= "futurecontractors"><%=futurecontractor%></td>


--another field on the form is a textbox which the user fills it. Once the value is filled I need to validate it. This value must be greater than futurecontractor(shown in code above).
so to do this i first request.form("futurecontractors") then

i have written a client side java script . LIke this


<script language="javascript">

function validateform()


     i need to check if this textbox is > futurecontractors


  if (Frmcontactnewfcs.Txtreleasemailto.value > chk with value that i got from request.form(futurecontractors) but i cant do this because thats server side which cant be inserted here in java scripts) {
        alert ('Please enter a number less than future contractors.);
        return false;
        }
 
Old September 16th, 2004, 09:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try this.
Code:
'Somewhere on top request this in to a variable
<%
Dim strfuturecontractors
strfuturecontractors = request.form(futurecontractors)
%>
...
...
'Within form validation function
if (Frmcontactnewfcs.Txtreleasemailto.value > eval('<%=strfuturecontractors%>')) {        
        alert ('Please enter a number less than future contractors.);
        return false;
}
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old September 17th, 2004, 08:16 AM
Authorized User
 
Join Date: Sep 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes thats what i was doing requesting that variable and then
comparing it in the function . but i dont think it seems to work in javascripts. it doesnt recognize eval('<%=strfuturecontractors%>')

 
Old September 17th, 2004, 09:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:it doesnt recognize eval('<%=strfuturecontractors%>')
How do you say that it doesn't recognize eval? eval is a Javascript function.

Do you face any error? How about posting the error that you could see than saying "I don't think it seems to work"?

If you are using IE, then at the bottom on the left-side in the status bar, you could see an exclamation symbol if javascript throws any error, double click if that shows up there, that should display a popup with the error.

What value does "Frmcontactnewfcs.Txtreleasemailto.value" hold?

_________________________
- Vijay G
Strive for Perfection
 
Old September 20th, 2004, 12:48 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sureshbabu Send a message via Yahoo to sureshbabu
Default

Hi
What i feel is , we dont need any eval function over there..
Thanks
Suresh Babu

 
Old September 20th, 2004, 01:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, it may or may not be used. But, basically what eval does is, it executes the string passed as parameter to it and is used when you want to execute some dynamic code.

Though, it works fine without it too here.

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone validation + web form validation morbo Struts 0 August 19th, 2008 04:02 AM
form validation EmWebs Dreamweaver (all versions) 6 January 23rd, 2007 10:01 AM
Form Validation aware Javascript How-To 1 July 15th, 2004 02:44 PM
Form not refreshing after form validation Mimi Javascript How-To 0 August 25th, 2003 03:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.