Help please anyone can help me with thisproject? JavaScript helps create right i
ID: 3609275 • Letter: H
Question
Help please anyone can help me with thisproject?
JavaScript helps create right information on theclient side without wasting the server resources, it validates thedata before passing it along to the server. Your company, a thirdparty vendor, wants to make sure that the information it needs toprocess is correct and validated. These data include name, address,zip code, social security number, DOB, and mother’s maidenname. Create a form for this purpose that validate the followingfields and will submit only when all those information are answeredin proper format.
Name
Address
Zip code
Social Sec. #
DOB
Mother’s maiden name
Name
Address
Zip code
Social Sec. #
DOB
Mother’s maiden name
Explanation / Answer
*******************************<script type='text/javascript'>
function formValidator(){ // Make quick references to our fields var firstname = document.getElementById('firstname'); var addr = document.getElementById('addr'); var zip = document.getElementById('zip'); var ssn = document.getElementById('ssn'); var dob = document.getElementById('dob'); var mmn = document.getElementById('mmn'); // Check each input in the order that it appears in theform! if(isAlphabet(firstname, "Please enter only letters for yourname")){ if(isAlphanumeric(addr, "Numbers and Letters Only forAddress")){ if(isNumeric(zip, "Please enter a valid zip code")){ if(isNumeric(ssn, "Numbers only in Social Security #Field")){ if(isNumeric(dob, "Numbers only in Date of BirthField")){ if(isAlphabet(mmn, "Please Alphabets only in Mother's MaidenName Field")){ return true; } } } } } } return false; }
function notEmpty(elem, helperMsg){ if(elem.value.length == 0){ alert(helperMsg); elem.focus(); // set the focus to this input return false; } return true; }
function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } }
function isAlphabet(elem, helperMsg){ var alphaExp = /^[a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } }
function isAlphanumeric(elem, helperMsg){ var alphaExp = /^[0-9a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } }
</script>
<form > First Name: <input type='text' id='firstname' /><br/> Address: <input type='text' id='addr' /><br/> Zip Code: <input type='text' id='zip' /><br/> Social Security No : <input type='text' id='ssn'/><br /> Date of Birth : <input type='text' id='dob' /><br/> Mother's Maiden Name <input type='text' id='mmn'/><br /> <input type='submit' value='Check Form' /> </form> <script type='text/javascript'>
function formValidator(){ // Make quick references to our fields var firstname = document.getElementById('firstname'); var addr = document.getElementById('addr'); var zip = document.getElementById('zip'); var ssn = document.getElementById('ssn'); var dob = document.getElementById('dob'); var mmn = document.getElementById('mmn'); // Check each input in the order that it appears in theform! if(isAlphabet(firstname, "Please enter only letters for yourname")){ if(isAlphanumeric(addr, "Numbers and Letters Only forAddress")){ if(isNumeric(zip, "Please enter a valid zip code")){ if(isNumeric(ssn, "Numbers only in Social Security #Field")){ if(isNumeric(dob, "Numbers only in Date of BirthField")){ if(isAlphabet(mmn, "Please Alphabets only in Mother's MaidenName Field")){ return true; } } } } } } return false; }
function notEmpty(elem, helperMsg){ if(elem.value.length == 0){ alert(helperMsg); elem.focus(); // set the focus to this input return false; } return true; }
function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } }
function isAlphabet(elem, helperMsg){ var alphaExp = /^[a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } }
function isAlphanumeric(elem, helperMsg){ var alphaExp = /^[0-9a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } }
</script>
<form > First Name: <input type='text' id='firstname' /><br/> Address: <input type='text' id='addr' /><br/> Zip Code: <input type='text' id='zip' /><br/> Social Security No : <input type='text' id='ssn'/><br /> Date of Birth : <input type='text' id='dob' /><br/> Mother's Maiden Name <input type='text' id='mmn'/><br /> <input type='submit' value='Check Form' /> </form> <script type='text/javascript'>
function formValidator(){ // Make quick references to our fields var firstname = document.getElementById('firstname'); var addr = document.getElementById('addr'); var zip = document.getElementById('zip'); var ssn = document.getElementById('ssn'); var dob = document.getElementById('dob'); var mmn = document.getElementById('mmn'); // Check each input in the order that it appears in theform! if(isAlphabet(firstname, "Please enter only letters for yourname")){ if(isAlphanumeric(addr, "Numbers and Letters Only forAddress")){ if(isNumeric(zip, "Please enter a valid zip code")){ if(isNumeric(ssn, "Numbers only in Social Security #Field")){ if(isNumeric(dob, "Numbers only in Date of BirthField")){ if(isAlphabet(mmn, "Please Alphabets only in Mother's MaidenName Field")){ return true; } } } } } } return false; }
function notEmpty(elem, helperMsg){ if(elem.value.length == 0){ alert(helperMsg); elem.focus(); // set the focus to this input return false; } return true; }
function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } }
function isAlphabet(elem, helperMsg){ var alphaExp = /^[a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } }
function isAlphanumeric(elem, helperMsg){ var alphaExp = /^[0-9a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } }
</script>
<form > First Name: <input type='text' id='firstname' /><br/> Address: <input type='text' id='addr' /><br/> Zip Code: <input type='text' id='zip' /><br/> Social Security No : <input type='text' id='ssn'/><br /> Date of Birth : <input type='text' id='dob' /><br/> Mother's Maiden Name <input type='text' id='mmn'/><br /> <input type='submit' value='Check Form' /> </form>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.