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!

How do I compare numbers in a natural order

Status
Not open for further replies.

axsom1

Technical User
Feb 27, 2001
67
US
My problem is our application requires client certificates. All I'm doing is retrieving the number of days left on the certificate and passing that into this little script.

<%
dim cert_days

cert_days = DateDiff("d", Now, Request.ClientCertificate("ValidUntil"))
%>

<script language="JavaScript1.2">
var days_left = "<%=cert_days%>";

function cert_date_check() {

if (days_left <= "15")
{
alert("Your certificate is only good for " + days_left +" more days.\nContact XXXXXXXX at (xxx) xxx-xxxx to request a new certificate");
}
}
</script>

My question is how do I compare the numbers correctly? Currently it will alert the user if they have 149 days or less left on the certificate.

Any help greatly appreciated!
John
 
Use parseInt to cast the number to an integer. Then you can make normal numerical comparisons.
Code:
<%
dim cert_days

cert_days = DateDiff("d", Now, Request.ClientCertificate("ValidUntil"))
%>

<script language="JavaScript1.2">
var days_left = [b]parseInt(<%=cert_days%>, 10)[/b];

function cert_date_check() {

    if (days_left <= 15)
    {
    alert("Your certificate is only good for " + days_left +" more days.\nContact XXXXXXXX at (xxx) xxx-xxxx to request a new certificate");
    }
}
</script>

-kaht

banghead.gif
 
DOH! Do I feel stupid or what... [flush]

Thanks for the quick reply...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top