HI,
I want the user to input http:// before entering any weblink address. If a user forgets, for example he put instead of , then on submit , either http:// should be inserted automatically before or only http:// should be inserted with cursor after it and an alert prompting the user to enter weblink address after the http://
I have written the following code but it add the weblink address even though first 7 char are not http://
<!---CF Includes Site Header, CSS Style Sheet and Side Menu--->
<cfinclude template="/Header.cfm">
<head>
<!--- Validate Web Link Description --->
<script language="javascript">
function validate(obj){
if(obj.weblinkdescription.value.length==0){
alert("Enter website description!"
;
obj.weblinkdescription.focus();
return false;
} else {
return true;
}
}
</script>
<!--- Text Validate Web link Address to http:// --->
<script language="javascript">
function validateWebAdd(weblinkaddress)
{
/*
This function will return true if the first 7 characters are equal to "*/
if (weblinkaddress.substring(0, 6) != " {
return false;
}
return true;
}
</script>
<title>CreateNewWebLink</title>
<!---CF Query Department database--->
<cfquery name="departmentsearch" datasource="staffdirectory">
SELECT deptID, dept
FROM tbldepartment
</cfquery>
</head>
<body>
<!---CF Form Action (submits to weblinksubmit.cfm)--->
<cfform action="SubmitNewWeblink.cfm" name="newweblink" method="POST" enctype="multipart/form-data" onsubmit="return validate(newweblink)">
<table>
<th colspan="2">Create New Web Link</th>
<tr>
<td>Site Name</td>
<td>
<cfinput type="text" name="weblinkName" MESSAGE="Website Name is required!" REQUIRED="Yes">
</td>
</tr>
<tr>
<td>Site Address</td>
<td>
<cfinput type="text" name="weblinkaddress"
MESSAGE="Website Address is required!" REQUIRED="Yes">i.e. </td>
</tr>
<tr>
<td>Department</td>
<td>
<cfinput type="text" name="weblinkdepartment" MESSAGE="Website Address is required!" value="#session.auth.dept#" REQUIRED="Yes">
<!---CF Department Search Output--->
</td>
</tr>
<tr>
<td>Description</td>
<td>
<textarea name="weblinkdescription" rows="6" cols="60"></textarea>
</td>
</tr>
<tr>
<td>Author</td>
<td>
<cfinput type="text" name="weblinkauthor" MESSAGE="Author Field is required!" Value="#session.auth.Lastname#, #session.auth.FirstName#" REQUIRED="Yes">
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" value="Submit"
onclick="validateWebAdd(document.forms[0].weblinkaddress.value)">
<input type="reset" name="Reset" value="Reset">
<input type="button" name="Button" value="Cancel" onClick="window.location='weblinks.cfm';">
</td>
</tr>
</table>
</cfform>
</body>
<cfinclude Template="/footer.cfm">
I want the user to input http:// before entering any weblink address. If a user forgets, for example he put instead of , then on submit , either http:// should be inserted automatically before or only http:// should be inserted with cursor after it and an alert prompting the user to enter weblink address after the http://
I have written the following code but it add the weblink address even though first 7 char are not http://
<!---CF Includes Site Header, CSS Style Sheet and Side Menu--->
<cfinclude template="/Header.cfm">
<head>
<!--- Validate Web Link Description --->
<script language="javascript">
function validate(obj){
if(obj.weblinkdescription.value.length==0){
alert("Enter website description!"
obj.weblinkdescription.focus();
return false;
} else {
return true;
}
}
</script>
<!--- Text Validate Web link Address to http:// --->
<script language="javascript">
function validateWebAdd(weblinkaddress)
{
/*
This function will return true if the first 7 characters are equal to "*/
if (weblinkaddress.substring(0, 6) != " {
return false;
}
return true;
}
</script>
<title>CreateNewWebLink</title>
<!---CF Query Department database--->
<cfquery name="departmentsearch" datasource="staffdirectory">
SELECT deptID, dept
FROM tbldepartment
</cfquery>
</head>
<body>
<!---CF Form Action (submits to weblinksubmit.cfm)--->
<cfform action="SubmitNewWeblink.cfm" name="newweblink" method="POST" enctype="multipart/form-data" onsubmit="return validate(newweblink)">
<table>
<th colspan="2">Create New Web Link</th>
<tr>
<td>Site Name</td>
<td>
<cfinput type="text" name="weblinkName" MESSAGE="Website Name is required!" REQUIRED="Yes">
</td>
</tr>
<tr>
<td>Site Address</td>
<td>
<cfinput type="text" name="weblinkaddress"
MESSAGE="Website Address is required!" REQUIRED="Yes">i.e. </td>
</tr>
<tr>
<td>Department</td>
<td>
<cfinput type="text" name="weblinkdepartment" MESSAGE="Website Address is required!" value="#session.auth.dept#" REQUIRED="Yes">
<!---CF Department Search Output--->
</td>
</tr>
<tr>
<td>Description</td>
<td>
<textarea name="weblinkdescription" rows="6" cols="60"></textarea>
</td>
</tr>
<tr>
<td>Author</td>
<td>
<cfinput type="text" name="weblinkauthor" MESSAGE="Author Field is required!" Value="#session.auth.Lastname#, #session.auth.FirstName#" REQUIRED="Yes">
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" value="Submit"
onclick="validateWebAdd(document.forms[0].weblinkaddress.value)">
<input type="reset" name="Reset" value="Reset">
<input type="button" name="Button" value="Cancel" onClick="window.location='weblinks.cfm';">
</td>
</tr>
</table>
</cfform>
</body>
<cfinclude Template="/footer.cfm">