Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Designer 7.0 javascript validation

Avatar

Former Community Member
It is not clear to me how to activate a validation by a Java script on a numeric field.



I try to put a javascript (validation) on a numeric field of a form in order to check the entered numbers (9 digits). This check is a calculation of the entered numbers which must have a specific outcome (must be completely divided by 11). The problem is that the application seems to ignore the calculation as there are no messages displayed when the field is entered with correct numbers as well as incorrect numbers: the form accepts all numbers. How can I execute the validation correctly? Your help is very much appreciated!



below the javascript:



<script language="javascript">

function checksofi(){

sofinr=document.sofi.nummer.value.toString();

checksum=0;

if(sofinr.length==8){

sofinr= "0"+sofinr;

}

if(isNaN(sofinr) || sofinr.length!=9){

alert("Uw Sofi-nummer moet acht of negen cijfers bedragen!\nZorg er ook voor dat het allemaal cijfers zijn die u invult.");

}

else{

for(i=0;i<8;i++){

checksum += (sofinr.charAt(i)*(9-i));

}

if(checksum%11!=sofinr.charAt(8)){

alert("Dit is geen geldig Sofi-nummer.\nGelieve het nummer nog eens te controleren.");

}

}

}

</script>
0 Replies