WebBees
%Europe/Berlin %764 %2009, 19:21
Ik ben een scriptje aan het uitwerken waar de bezoeker zijn gsm nummer moet opgeven, daarna wordt er op een button gedrukt en dan controleert het script of er het juist aantal cijfers zijn ingegeven. (Er wordt ook gecontroleerd en gecorrigeerd bij leestekens, spaties en letters)...
input text field = input_txt
dynamic text field (voor errors) = output_txt
button = verzenden_btn
stop();
this.output_txt.text = "";
function numOnlyMaxLen(maxLen, inputTxt, onSuccess) {
var theText = input_txt.text;
if (theText.length == maxLen) {
onSuccess();
} else {
noSuccess();
}
var replacement = "";
for (var i = 0; i<theText.length; i++) {
var curCode = theText.charCodeAt(i);
if (curCode<48 || curCode>57) {
input_txt.text = replacement;
} else {
replacement += theText.charAt(i);
}
}
}
this.onEnterFrame = function() {
verzenden_btn.onRelease = function() {
numOnlyMaxLen(10,input_txt,onSuccess);
};
};
function onSuccess() {
gotoAndStop(15);
}
function noSuccess() {
output_txt.text = "Foutief GSM nummer!";
}
Nu alles werkt... :)
Niet alles dus , als ik een juist nummer ingeef (10 cijfers) en druk dan op de button, dan krijg ik een error. Als ik zonder wijzigen nog eens druk, gaat ie verder...
Kan iemand me vertellen waarom ik 2 keer moet drukken?
Thx
input text field = input_txt
dynamic text field (voor errors) = output_txt
button = verzenden_btn
stop();
this.output_txt.text = "";
function numOnlyMaxLen(maxLen, inputTxt, onSuccess) {
var theText = input_txt.text;
if (theText.length == maxLen) {
onSuccess();
} else {
noSuccess();
}
var replacement = "";
for (var i = 0; i<theText.length; i++) {
var curCode = theText.charCodeAt(i);
if (curCode<48 || curCode>57) {
input_txt.text = replacement;
} else {
replacement += theText.charAt(i);
}
}
}
this.onEnterFrame = function() {
verzenden_btn.onRelease = function() {
numOnlyMaxLen(10,input_txt,onSuccess);
};
};
function onSuccess() {
gotoAndStop(15);
}
function noSuccess() {
output_txt.text = "Foutief GSM nummer!";
}
Nu alles werkt... :)
Niet alles dus , als ik een juist nummer ingeef (10 cijfers) en druk dan op de button, dan krijg ik een error. Als ik zonder wijzigen nog eens druk, gaat ie verder...
Kan iemand me vertellen waarom ik 2 keer moet drukken?
Thx