Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

having problems in validating form using both vbscript and javscript

Status
Not open for further replies.

icy111

Programmer
Dec 13, 2001
39
US
Hi,

I am validating form using both vbscript and javascript. I am getting the dynamic input data from web page using vbscript and validating the field with javascript on client-side before i submitting to database. I am facing problem where Javascript doesn't recognize those variables in <%=variable%> since I am getting the input with vbscript. Is there any way that Jscript and vbscript can communicate each other or any help. Here is the my code...

-----------------------------------------------------
Javascript:

function validateCreateForm(formCreate){
var errors
errors = ''

if(document.formCreate.txtGoals_<%=strSCID%>.value == "" || document.formCreate.txtGoals_<%=strSCID%>.value == null) {
errors += '- Please enter the Goals.\n';
}

if(document.formCreate.txtAch_<%=strSCID%>.value == "" || document.formCreate.txtAch_<%=strSCID%>.value == null) {
errors += '- Please enter the Goals.\n';
}


if (errors){
alert('The following error(s) occurred:\n'+errors);
return false;
}
else {
return true;
}
}
-----------------------------------------------------
HTML Code:

<tr bgcolor="#FFEEBB" class="formtext">
<td bgcolor="#FFEEBB" class="trborder"><%=rstScWt("ScoreWeightCode")%> - <%=rstScWt("ScoreWeightDetails")%></td>
<td class="trborder"><textarea name="txtGoals_<%=strSCID%>" cols="35" class="text" rows="4" wrap="virtual"></textarea></td>
<td class="trborder"><textarea name="txtAch_<%=strSCID%>" cols="35" class="text" rows="4" wrap="virtual"></textarea></td>
<td class="trborder"><div align="center"><input name="txtRawScore_<%=strSCID%>" type="text" classs="text" size="4" maxlength="4">
</div></td>
<td class="trborder"><textarea name="txtSCRemarks_<%=strSCID%>" cols="35" class="text" rows="4" wrap="virtual"></textarea></td>
</tr>
-----------------------------------------------------
 

Are you talking server-side VBScript and client-side JS, or are you talking server-side VBScript and server-side JS?

Why not do the validation server-side? It'd be safer (in that it would be harder to bypass).

Dan
 
Hi Dan,

I am referring to server-side VBScript and client-side JS.

icy111
 
You cannot communicate from Javascript to VBScript in the situation you have described (where one is server-side and the other, client-side).

Assuming you are accessing the page through a web server (IIS), then the <%=XXX%> code will always resolve to the variable contents of XXX. If you "view source" in your web browser, and you see the <%=XXX%> code still in there, then the problem may be with your IIS server.

Jeff
 
Thanks Jeff for the information.
In that case, i will think of another alternative in solving that problem.

Hi simonchristieis,
Thanks for your help. I think what Jeff has replied is quite true. I will modify my code.

regards
icy111
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top