﻿//client file: captcha.js
//need: clientapi.js, jQuery Library
function Captcha(imageId) {
    this.imageId = imageId;
    this.validateUrl;
    this.pathUrl;
}

Captcha.prototype.validate = function(value) {
    var result = $.ajax({
        url: this.validateUrl,
        data: { code: value },//hardcode "code"
        cache: false,
        async: false
    }).responseText

    r = result.split(":");
    isValid = Boolean(r[0]);
    if (!isValid && r.length > 1) {
        getElement(this.imageId).src = this.pathUrl + r[1];
    }
    return isValid;
}