
<mvc:View controllerName="captcha.controller.View1"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m">
<App>
<pages>
<Page title="{i18n>title}">
<content >
<Vbox class="sapUiResponsiveMargin">
<Text text="Please Enter the Captcha"/>
<Hbox >
<Input editable="false" id="generatecaptcha" value="" width="90%"/>
<Button press="onRefresh" text="Refresh"/>
</Hbox>
<Input id="captchacheck" value="" width="15%"/>
<Button press="onValidate" text="Check"/>
</Vbox>
</content>
</Page>
</pages>
</App>
</mvc:View>sap.ui.define(["./Captcha"], function() {
return {
customMethod: function() {
var alpha = new Array("A", "B", "C", "D", "E", "F", "G","H", "I", "J",
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
"U", "V", "W","X", "Y", "Z", "a", "b", "c", "d",
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
"y", "z");
var i;
for (i = 0; i < 6; i++) {
var a = alpha[Math.floor(Math.random() * alpha.length)];
var b = Math.ceil(Math.random() * 10) + "";
var c = alpha[Math.floor(Math.random() * alpha.length)];
var d = alpha[Math.floor(Math.random() * alpha.length)];
var e = Math.ceil(Math.random() * 10) + "";
var f = alpha[Math.floor(Math.random() * alpha.length)];
var g = alpha[Math.floor(Math.random() * alpha.length)];
}
var code = a + " " + b + " " + " " + c + " " + d + " " + e + " " + f + " " + g;
var bCode = code.split(" ").join("");
return bCode;
}
};
});onInit: function() {
var that = this;
sap.ui.require(["captcha/controller/captcha"], function(captcha) {
var sCaptcha = captcha.customMethod();
that.byId("generatecaptcha").setValue(sCaptcha);
});
},onRefresh: function() {
var that = this;
sap.ui.require(["captcha/controller/captcha"], function(captcha) {
var rCaptcha = captcha.customMethod();
that.byId("generatecaptcha").setValue(rCaptcha);
});
},onValidate: function() {
var Input1 = this.byId("generatecaptcha").getValue();
var Input2 = this.byId("captchacheck").getValue();
if (Input2 === "") {
alert("Please enter the captcha");
}
else if (Input1 === Input2) {
alert("Validation is Correct");
var that = this;
sap.ui.require(["captcha/controller/captcha"], function(captcha) {
var captchaCorrect = captcha.customMethod();
that.byId("generatecaptcha").setValue(captchaCorrect);
});
this.byId("captchacheck").setValue("");
}
else {
alert("Validation is wrong");
var that = this;
sap.ui.require(["captcha/controller/captcha"], function(captcha) {
var captchaWrong = captcha.customMethod();
that.byId("generatecaptcha").setValue(captchaWrong);
});
this.byId("captchacheck").setValue("");
}
}


You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 29 | |
| 25 | |
| 24 | |
| 19 | |
| 14 | |
| 13 | |
| 12 | |
| 11 | |
| 11 | |
| 10 |