Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hellow , How to write code html ,css and javascript for valdation id number by this code: Note: I need two fields of the same

hellow , How to write code html ,css and javascript for valdation id number by this code:
Note: I need two fields of the same type. Also, how do I make the verification result appear as text below the field and not in the alert()?
/////////////
/**
* @return {number}
*/
function validateSAID(id) {
id = id.trim();
if (isNaN(parseInt(id))) {
return -1;
}
if (id.length !== 10) {
return -1;
}
const type = id.substr(0, 1);
if (type !== '2' && type !== '1') {
return -1;
}
var sum = 0;
for (var i = 0; i < 10; i++) {
if (i % 2 === 0) {
const ZFOdd = String('00' + String(Number(id.substr(i, 1)) * 2)).slice(-2);
sum += Number(ZFOdd.substr(0, 1)) + Number(ZFOdd.substr(1, 1));
} else {
sum += Number(id.substr(i, 1));
}
}
return (sum % 10 !== 0) ? -1 : type;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

2. Are you varying your pitch (to avoid being monotonous)?

Answered: 1 week ago

Question

3. Are you varying your speaking rate and volume?

Answered: 1 week ago