{"id":26493,"date":"2021-04-26T23:10:07","date_gmt":"2021-04-27T03:10:07","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/javascript-form-validation-validate-a-form-collecting-credit-card-information-programming-code-examples-javascript-javascript\/"},"modified":"2021-04-26T23:10:07","modified_gmt":"2021-04-27T03:10:07","slug":"javascript-form-validation-validate-a-form-collecting-credit-card-information-programming-code-examples-javascript-javascript","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=26493","title":{"rendered":"JavaScript Form Validation: Validate a Form Collecting Credit Card Information #Programming Code Examples #Javascript #JavaScript"},"content":{"rendered":"<pre style='font-size:12px;padding:10px'>\n\n\tfunction validateCollectPaymentInformationForm()\n\t{\n\t\tvar method, name, number, expiry, errMsg\n\t\t\n\t\terrMsg = &quot;&quot;;\n\t\t\n\t\tmethod = document.getElementById('paymentMethod');\n\t\tname =   document.getElementById('txtCCName');\n\t\tnumber = document.getElementById('txtCCNumber');\n        \n\t\tif (method.value == &quot;&quot; || method.value == &quot;0&quot; || method.value == null){\n\t\t\t\n\t\t\terrMsg = &quot;Please select a payment method n&quot;;\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t\tif (name.value == &quot;&quot; || name.value == null){\n\t\t\t\n\t\t\terrMsg = errMsg + 'Please write down your name  n';\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t\tif (number.value == &quot;&quot; || number.value == null){\n\t\t\t\n\t\t\terrMsg = errMsg + 'Please provide credit card number  n';\n\t\t\t\t\n\t\t}else if (number.value.length  0 ){\n\t\t\talert(errMsg);\n\t\t\tmethod.focus();\n\t\t\treturn false;\t\t\t\n\t\t}else{\t\t\n\t\t\treturn true;\n\t\t}\t\t\n\t\treturn false;\t\n\t}\n\n\n\tfunction validateCollectPaymentInformationForm()\n\t{\n\t\tvar method, name, number, expiry, errMsg\n\t\t\n\t\t\n\t\t\n\t\tmethod = document.getElementById('paymentMethod');\n\t\tname =   document.getElementById('txtCCName');\n\t\tnumber = document.getElementById('txtCCNumber');\n        \n\t\tif (method.value == &quot;&quot; || method.value == &quot;0&quot; || method.value == null){\n\t\t\talert('Please select a payment method');\n\t\t\tmethod.focus();\n\t\t\treturn false;\n\t\t\t\n\t\t}\n\t\t\n\t\tif (name.value == &quot;&quot; || name.value == null){\n\t\t\talert('Please write down your name');\t\t\t\n\t\t\tname.focus();\n\t\t\treturn false;\n\t\t\t\n\t\t}\n\t\t\n\t\tif (number.value == &quot;&quot; || number.value == null){\n\t\t\talert('Please provide credit card number');\t\t\t\n\t\t\tnumber.focus();\n\t\t\treturn false;\t\t\t\n\t\t}else if (number.value.length &lt; 16 ){\n\t\t\talert(&#039;Invalid card number&#039;);\t\t\t\n\t\t\tnumber.focus();\n\t\t\treturn false;\t\n\t\t}\n\t\t\n\t\t\n\t\t\t\n\t\treturn true;\n\t}\n\n\n\n<\/pre>\n<p>Note: Brought from our old site: http:\/\/www.salearningschool.com\/example_codes\/ on Jan 2nd, 2017 From: http:\/\/sitestree.com\/?p=10176<br \/> Categories:Programming Code Examples, Javascript, JavaScript<br \/>Tags:JavascriptJavaScript<br \/> Post Data:2017-01-02 16:04:23<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>function validateCollectPaymentInformationForm() { var method, name, number, expiry, errMsg errMsg = &quot;&quot;; method = document.getElementById(&#8216;paymentMethod&#8217;); name = document.getElementById(&#8216;txtCCName&#8217;); number = document.getElementById(&#8216;txtCCNumber&#8217;); if (method.value == &quot;&quot; || method.value == &quot;0&quot; || method.value == null){ errMsg = &quot;Please select a payment method n&quot;; } if (name.value == &quot;&quot; || name.value == null){ errMsg = errMsg + &#8216;Please &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=26493\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1917],"tags":[],"class_list":["post-26493","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":10560,"url":"http:\/\/bangla.sitestree.com\/?p=10560","url_meta":{"origin":26493,"position":0},"title":"JavaScript Form Validation: Validate a Form Collecting Credit Card Information","author":"","date":"August 29, 2015","format":false,"excerpt":"\u00a0\u00a0 \u00a0function validateCollectPaymentInformationForm() \u00a0\u00a0 \u00a0{ \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0var method, name, number, expiry, errMsg \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0errMsg = \"\"; \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0method = document.getElementById('paymentMethod'); \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0name =\u00a0\u00a0 document.getElementById('txtCCName'); \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0number = document.getElementById('txtCCNumber'); \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if (method.value == \"\" || method.value ==\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65804,"url":"http:\/\/bangla.sitestree.com\/?p=65804","url_meta":{"origin":26493,"position":1},"title":"JavaScript &#8211; Miscellaneous Validations #JavaScript","author":"Author-Check- Article-or-Video","date":"July 15, 2021","format":false,"excerpt":"function validateDomainName(strValue) { return \/www.[a-z0-9_-]+.[a-z]{2, 3}\/ig.test(strValue); } function validateDomainName(strValue) { return \/www.[a-z0-9_-]+.[a-z]{2, 3}\/ig.test(strValue); } \/\/not 100% right, will fix later function checkDateFormat() { var pattern = new RegExp(0|1[0-9]\/[0-3][0-9]\/[0-9][0-9]); if(document.getElementById('timestampStarted').value.match(pattern)) { var date_array = document.getElementById('timestampStarted').value.split('\/'); var month = date_array[0]; var day = date_array[1]; var year = date_array[2]; \/\/ This instruction will\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":70135,"url":"http:\/\/bangla.sitestree.com\/?p=70135","url_meta":{"origin":26493,"position":2},"title":"JavaScript &#8211; Miscellaneous Validations #13","author":"Author-Check- Article-or-Video","date":"August 27, 2021","format":false,"excerpt":"function validateDomainName(strValue) { return \/www.[a-z0-9_-]+.[a-z]{2, 3}\/ig.test(strValue); } function validateDomainName(strValue) { return \/www.[a-z0-9_-]+.[a-z]{2, 3}\/ig.test(strValue); } \/\/not 100% right, will fix later function checkDateFormat() { var pattern = new RegExp(0|1[0-9]\/[0-3][0-9]\/[0-9][0-9]); if(document.getElementById('timestampStarted').value.match(pattern)) { var date_array = document.getElementById('timestampStarted').value.split('\/'); var month = date_array[0]; var day = date_array[1]; var year = date_array[2]; \/\/ This instruction will\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65806,"url":"http:\/\/bangla.sitestree.com\/?p=65806","url_meta":{"origin":26493,"position":3},"title":"JavaScript Codes #JavaScript","author":"Author-Check- Article-or-Video","date":"July 15, 2021","format":false,"excerpt":"JavaScript is a very powerful scripting language for web-site development. Also, it is in much demand. var serviceInstancesArrAtLoad = Array(); var serviceInstancesArrAtSubmit = Array(); var tempArr=Array(); function validate_required(field,alerttxt) { with (field) { if (value==null||value=='') { alert(alerttxt);return false } else {return true} } } function validateTicketCreateForm(thisform) { with (thisform) { if\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26499,"url":"http:\/\/bangla.sitestree.com\/?p=26499","url_meta":{"origin":26493,"position":4},"title":"JavaScript Code #Programming Code Examples #Javascript #JavaScript","author":"Author-Check- Article-or-Video","date":"April 26, 2021","format":false,"excerpt":"var browser=navigator.appName; var b_version=navigator.appVersion; <a href=\"http:\/\/www.justetc.net\" target=\"_blank\"> <img border=\"0\" alt=\"hello\" src=\"b_pink.gif\" id=\"b1\" width=\"26\" height=\"26\" onmouseover=\"mouseOver()\" onmouseout=\"mouseOut()\" \/> Place the following code under script tag\/in a javascript file function mouseOver() { document.getElementById(\"b1\").src =\"b_blue.gif\"; } function mouseOut() { document.getElementById(\"b1\").src =\"b_pink.gif\"; } <map name=\"planetmap\"> <area shape =\"rect\" coords =\"0,0,82,126\" onMouseOver=\"writeText('You are over the\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27156,"url":"http:\/\/bangla.sitestree.com\/?p=27156","url_meta":{"origin":26493,"position":5},"title":"Javascript : Miscellaneous Code #Programming Code Examples #Java\/J2EE\/J2ME #Ajax","author":"Author-Check- Article-or-Video","date":"May 12, 2021","format":false,"excerpt":"var browser=navigator.appName; var b_version=navigator.appVersion; <a href=\"http:\/\/www.justetc.net\" target=\"_blank\"> <img border=\"0\" alt=\"hello\" src=\"b_pink.gif\" id=\"b1\" width=\"26\" height=\"26\" onmouseover=\"mouseOver()\" onmouseout=\"mouseOut()\" \/> Place the following code under script tag\/in a javascript file function mouseOver() { document.getElementById(\"b1\").src =\"b_blue.gif\"; } function mouseOut() { document.getElementById(\"b1\").src =\"b_pink.gif\"; } <map name=\"planetmap\"> <area shape =\"rect\" coords =\"0,0,82,126\" onMouseOver=\"writeText('You are over the\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26493"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26493\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26493"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}