asp vbscript textbox paste from word problem

G

GTN170777

Hi Guys,

It's been a while, I've got a small problem that I could do with your
expertise on.
As you know (I Think) I build websites for recruitment agencies, part of the
website includes a job board facility and for job form entry I used a normal
form with a normal textbox, however what I'm finding now is that a lot of
recruitment consultants are pasting the job description into the textbox,
which when submitted is resulting in most of the text not being entered!!!

Is there any way around this?

I've attached the code -

Thank you

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/recruta2.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<% Session("NEWVACANCYTITLE") = Request.Form("title") %>
<% Session("NEWVACANCYSECTOR") = Request.Form("jobtype") %>
<% Session("NEWVACANCYLOCATION") = Request.Form("location") %>
<%
If (CStr(Request("MM_insert")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_recruta2_STRING
MM_editCmd.CommandText = "INSERT INTO dbo.Vacancy (VacancyTitle,
VacancyCategory, VacancyLocation, VacancyType, VacancyPaye, VacancyDuration,
VacancyReference, VacancyExpiryDate, VacancyDescription, VacancyEmployerID,
VacancyEmployeeID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202,
1, 50, Request.Form("title")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202,
1, 50, Request.Form("jobtype")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202,
1, 50, Request.Form("location")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202,
1, 50, Request.Form("contract")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202,
1, 50, Server.HTMLEncode(Request.Form("payrate"))) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202,
1, 50, Request.Form("duration")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 202,
1, 50, Request.Form("reference")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 135,
1, -1, MM_IIF(Request.Form("expirydate2"), Request.Form("expirydate2"),
null)) ' adDBTimeStamp
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 201,
1, -1, Server.HTMLEncode(Request.Form("description"))) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 5, 1,
-1, MM_IIF(Request.Form("SITEID"), Request.Form("SITEID"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 5, 1,
-1, MM_IIF(Request.Form("Employee"), Request.Form("Employee"), null)) '
adDouble
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "afternewvacancy.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/javascript" src="../Scripts/currentdate.js"></script>
<%
Function fRandomReference()
Const sValidChars = "abcdefghijklmnopqrstuvxyz"
Dim nCount
Dim sRet
Dim nNumber
Dim nLength
Randomize
nLength = Len( sValidChars )
For nCount = 1 To 10
nNumber = Int((nLength * Rnd) + 1)
sRet = sRet & Mid( sValidChars, nNumber, 1 )
Next
fRandomReference = sRet
End Function
%><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Backoffice</title>
<meta name="robots" content="noindex,nofollow">
<link href="Styles/clientsheet.css" rel="stylesheet" type="text/css">
<link href="Styles/clientforms.css" rel="stylesheet" type="text/css">
<meta http-equiv="refresh" content="1201;URL=index.asp">
<script src="../SpryAssets/SpryCollapsiblePanel.js"
type="text/javascript"></script>
<script type="text/javascript" src="../Scripts/reflection.js"></script>
<script src="../calendar/calendar.js"></script>
<link href="../SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet"
type="text/css" />
<script type="text/javascript" src="../Scripts/check.js"></script>
</head>
<body>
<div id="wrapper">
<table border="0" cellpadding="0" cellspacing="0" class="table">
<tr>
<td class="toptablebackoffice"><table border="0" cellpadding="0"
cellspacing="0" class="toptablebackoffice">
<tr>
<td><img src="../images/recrutalg.jpg" alt="Recruta" width="179"
class="reflect rheight50 ropacity33" id="recrlogo" /></td>
<td><table border="0" cellpadding="0" cellspacing="0"
class="toptablebackoffice2">
<tr>
<td class="recrutadate"><script language="JavaScript"
type="text/javascript">
document.write("<span
class=\"datetext\">"+doClock("W0","%20","D0","%20","M0","%20","Y0")+"</span>");
</script></td>
</tr>
<tr>
<td class="loggedin"><%= Session("NAME") %> you are logged in
</td>
</tr>
</table></td>
</tr>

</table></td>
</tr>
<tr>
<td class="tdrecrutanavbar"><ul class="nav">
<% If Not adminlevel.EOF Or Not adminlevel.BOF Then %>
<li><a href="pagelist.asp">Page Manager</a></li>
<li><a href="consultantlist.asp">Consultant Manager</a></li>
<li><a href="newslist.asp">News Manager</a></li>
<li><a href="jobsearchcriteria.asp">JobSearch Manager</a></li>
<% End If ' end Not adminlevel.EOF Or NOT adminlevel.BOF %>
<li><a href="oldregcandlist.asp">Registered Users</a></li>
<li><a href="jbemgnt.asp">Jobs by Email Manager</a></li>
<li><a href="account.asp">Account</a></li>
<li><a href="logout.asp">Log Out</a></li>
</ul></td>
</tr>
<tr>
<td><table border="0" cellpadding="0" cellspacing="0"
class="recrutamainarea">
<tr>
<td valign="top" class="tdrightrecrutamain"><h1>New Vacancy </h1>


<p class="invalid">Please complete all fields </p>
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="form1"
id="form1">
<table border="0" cellpadding="0" cellspacing="0"
class="outervacancytable">
<tr>
<td class="editvacancyvalue">Vacancy Title:</td>
<td class="editvacancyform"><label>
<input name="title" type="text" id="title"
maxlength="50" />
</label></td>
</tr>
<tr>
<td class="editvacancyvalue">Sector:</td>
<td class="editvacancyform"><label>
<select name="jobtype" id="jobtype">
<option selected="selected" value="">Select</option>
<%
While (NOT jobsectors.EOF)
%>
<option
value="<%=(jobsectors.Fields.Item("Jobtype").Value)%>"><%=(jobsectors.Fields.Item("Jobtype").Value)%></option>
<%
jobsectors.MoveNext()
Wend
If (jobsectors.CursorType > 0) Then
jobsectors.MoveFirst
Else
jobsectors.Requery
End If
%>
</select>
</label></td>
</tr>
<tr>
<td class="editvacancyvalue">Location:</td>
<td class="editvacancyform"><label>
<select name="location" id="location">
<option selected="selected" value="">Select</option>
<%
While (NOT joblocations.EOF)
%>
<option
value="<%=(joblocations.Fields.Item("JobLocation").Value)%>"><%=(joblocations.Fields.Item("JobLocation").Value)%></option>
<%
joblocations.MoveNext()
Wend
If (joblocations.CursorType > 0) Then
joblocations.MoveFirst
Else
joblocations.Requery
End If
%>
</select>
</label></td>
</tr>
<tr>
<td class="editvacancyvalue">Type:</td>
<td class="editvacancyform"><label>
<select name="contract" id="contract">
<option selected="selected" value="">Select</option>
<option value="Temporary">Temporary</option>
<option value="Permanent">Permanent</option>
<option value="Contract">Contract</option>
</select>
</label></td>
</tr>
<tr>
<td class="editvacancyvalue">Pay Rate:</td>
<td class="editvacancyform"><label>
<input name="payrate" type="text" id="payrate"
maxlength="50" />
</label></td>
</tr>
<tr>
<td class="editvacancyvalue">Duration:</td>
<td class="editvacancyform"><label>
<input name="duration" type="text" id="duration"
maxlength="50" />
<input name="reference" type="hidden" id="reference"
value="<%=fRandomReference()%>" />
</label></td>
</tr>
<tr>
<td class="editvacancyvalue">Advert Expires on:</td>
<td class="editvacancyform">
<input name="expirydate2" type="text" id="expirydate2"
onFocus="this.select();lcs(this)"
onClick="event.cancelBubble=true;this.select();lcs(this)">
</td>
</tr>
<tr>
<td class="editvacancyvalue">Description:</td>
<td class="editvacancyform"><label>
<textarea name="description" id="description"
rows="14"></textarea>
</label></td>
</tr>
<tr>
<td><input name="SITEID" type="hidden" id="SITEID"
value="<%= Session("SITEID") %>" />
<input name="Employee" type="hidden" id="Employee"
value="<%= Session("EMPLOYEEID") %>" /></td>
<td class="editbutton"><label>
<input name="submit" type="submit" id="submit"
value="Submit" />
</label></td>
</tr>
</table>



<input type="hidden" name="MM_insert" value="form1" />
</form>

I've removed some of the not important stuff -- thanks
 
T

Tim Slattery

GTN170777 said:
Hi Guys,

It's been a while, I've got a small problem that I could do with your
expertise on.
As you know (I Think) I build websites for recruitment agencies, part of the
website includes a job board facility and for job form entry I used a normal
form with a normal textbox, however what I'm finding now is that a lot of
recruitment consultants are pasting the job description into the textbox,
which when submitted is resulting in most of the text not being entered!!!

You didn't say which textbox is getting the problem, but I see three
<input type="text" ...> controls, named "title", "payrate", and
"duration", that have a maxlength attribute of 50. Anything longer
then 50 characters that's pasted into any of these will be truncated.
 
A

Adrienne Boswell

Gazing into my crystal ball I observed =?Utf-8?B?R1ROMTcwNzc3?=
It's been a while, I've got a small problem that I could do with your
expertise on.
As you know (I Think) I build websites for recruitment agencies, part
of the website includes a job board facility and for job form entry I
used a normal form with a normal textbox, however what I'm finding now
is that a lot of recruitment consultants are pasting the job
description into the textbox, which when submitted is resulting in
most of the text not being entered!!!

Is there any way around this?

You can use client side javascript to show the user how many characters
are left, and alert the user that the data was truncated.

Server side, check the length of the data, and return an error message
to the client if it is too long.

Including instructions on the form that the input should only be a
certain amount of characters will also help.
 
B

Bob Milutinovic

GTN170777 said:
Hi Guys,

It's been a while, I've got a small problem that I could do with your
expertise on.
As you know (I Think) I build websites for recruitment agencies, part of
the
website includes a job board facility and for job form entry I used a
normal
form with a normal textbox, however what I'm finding now is that a lot of
recruitment consultants are pasting the job description into the textbox,
which when submitted is resulting in most of the text not being entered!!!

Is there any way around this?

Silly question time... What's the defined size of the VacancyDescription
column in the database?

- Bob.
 
B

B@DJJ

Aye - that's my guess too - if it's varchar(n) the DB won't complain if you
try to stuff n+1000 into it, it'll just truncate (silently) at n when the
data is put into the DB.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top