Initial commit: DMH Patient Registration Flask app

This commit is contained in:
Ayush
2026-11-27 17:07:03 +05:30
commit 6c03977aab
34 changed files with 5445 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
/* Minimal DOM helper compatible with the registration form's jQuery usage */
(function(global) {
function selectElements(sel) {
if (!sel) return [];
if (typeof sel === "function") {
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", sel);
} else {
sel();
}
return [];
}
if (typeof sel === "string") {
return Array.prototype.slice.call(document.querySelectorAll(sel));
}
if (sel === document || sel === window || sel.nodeType) {
return [sel];
}
return [];
}
function MiniQuery(sel) {
if (!(this instanceof MiniQuery)) return new MiniQuery(sel);
this.els = selectElements(sel);
}
MiniQuery.prototype.ready = function(fn) {
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", fn);
} else {
fn();
}
return this;
};
MiniQuery.prototype.show = function() {
this.els.forEach(function(el) { el.style.display = ""; });
return this;
};
MiniQuery.prototype.hide = function() {
this.els.forEach(function(el) { el.style.display = "none"; });
return this;
};
MiniQuery.prototype.html = function(val) {
if (val === undefined) return this.els[0] ? this.els[0].innerHTML : "";
this.els.forEach(function(el) { el.innerHTML = val; });
return this;
};
MiniQuery.prototype.append = function(htmlStr) {
this.els.forEach(function(el) { el.insertAdjacentHTML("beforeend", htmlStr); });
return this;
};
MiniQuery.prototype.bind = function(events, fn) {
var evList = events.split(/\s+/);
this.els.forEach(function(el) {
evList.forEach(function(ev) { el.addEventListener(ev, fn); });
});
return this;
};
MiniQuery.prototype.keydown = function(fn) {
return this.bind("keydown", fn);
};
MiniQuery.noConflict = function() {
return MiniQuery;
};
MiniQuery.fn = MiniQuery.prototype;
global.$ = MiniQuery;
global.jQuery = MiniQuery;
})(window);
+32
View File
@@ -0,0 +1,32 @@
.dmh-datepicker-popup {
position: absolute;
z-index: 9999;
background: #fff;
border: 1px solid #ccc;
border-radius: 4px;
padding: 8px;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
width: 240px;
}
.dmh-dp-header {
display: flex;
justify-content: space-between;
margin-bottom: 6px;
gap: 6px;
}
.dmh-dp-header select { flex: 1; padding: 2px; }
.dmh-dp-grid {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 3px;
}
.dmh-dp-grid button {
border: 1px solid #e0e0e0;
background: #f8f9fa;
padding: 4px 0;
cursor: pointer;
border-radius: 2px;
font-size: 12px;
}
.dmh-dp-grid button:hover:not(:disabled) { background: #007bff; color: #fff; }
.dmh-dp-grid button:disabled { opacity: 0.4; cursor: not-allowed; }
+100
View File
@@ -0,0 +1,100 @@
/* Lightweight dd/mm/yyyy datepicker compatible with $(selector).datepicker(opts) */
(function($) {
if (!$ || !$.fn) return;
function pad(n) { return n < 10 ? "0" + n : "" + n; }
$.fn.datepicker = function(opts) {
opts = opts || {};
this.els.forEach(function(input) {
var popup = null;
function closePopup() {
if (popup && popup.parentNode) {
popup.parentNode.removeChild(popup);
popup = null;
}
}
function renderCalendar(year, month) {
closePopup();
popup = document.createElement("div");
popup.className = "dmh-datepicker-popup";
var rect = input.getBoundingClientRect();
popup.style.top = (window.scrollY + rect.bottom + 2) + "px";
popup.style.left = (window.scrollX + rect.left) + "px";
var header = document.createElement("div");
header.className = "dmh-dp-header";
var monthSel = document.createElement("select");
var months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
months.forEach(function(m, idx) {
var o = document.createElement("option");
o.value = idx;
o.textContent = m;
if (idx === month) o.selected = true;
monthSel.appendChild(o);
});
var yearSel = document.createElement("select");
var curYear = new Date().getFullYear();
for (var y = curYear; y >= curYear - 100; y--) {
var oy = document.createElement("option");
oy.value = y;
oy.textContent = y;
if (y === year) oy.selected = true;
yearSel.appendChild(oy);
}
monthSel.onchange = function() { renderCalendar(parseInt(yearSel.value, 10), parseInt(monthSel.value, 10)); };
yearSel.onchange = function() { renderCalendar(parseInt(yearSel.value, 10), parseInt(monthSel.value, 10)); };
header.appendChild(monthSel);
header.appendChild(yearSel);
popup.appendChild(header);
var grid = document.createElement("div");
grid.className = "dmh-dp-grid";
var daysInMonth = new Date(year, month + 1, 0).getDate();
var today = new Date();
today.setHours(0, 0, 0, 0);
for (var d = 1; d <= daysInMonth; d++) {
(function(dayNum) {
var btn = document.createElement("button");
btn.type = "button";
btn.textContent = dayNum;
var candidate = new Date(year, month, dayNum);
if (opts.maxDate === "0" && candidate > today) {
btn.disabled = true;
}
btn.onclick = function() {
var formatted = pad(dayNum) + "/" + pad(month + 1) + "/" + year;
input.value = formatted;
closePopup();
if (typeof opts.onSelect === "function") {
opts.onSelect(formatted);
}
};
grid.appendChild(btn);
})(d);
}
popup.appendChild(grid);
document.body.appendChild(popup);
}
input.addEventListener("click", function() {
if (input.readOnly) return;
var now = new Date();
renderCalendar(now.getFullYear(), now.getMonth());
});
document.addEventListener("click", function(ev) {
if (popup && ev.target !== input && !popup.contains(ev.target)) {
closePopup();
}
});
});
return this;
};
})(window.$);
+1
View File
@@ -0,0 +1 @@
/* Calendar touch style placeholder */
+45
View File
@@ -0,0 +1,45 @@
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 1rem; line-height: 1.5; color: #212529; }
.bg-light { background-color: #f8f9fa !important; }
.container { width: 100%; max-width: 1140px; padding: 0 15px; margin: 0 auto; }
.py-5 { padding-top: 3rem !important; padding-bottom: 3rem !important; }
.pt-5 { padding-top: 3rem !important; }
.my-5 { margin-top: 3rem !important; margin-bottom: 3rem !important; }
.mb-1 { margin-bottom: .25rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.d-block { display: block !important; }
.w-100 { width: 100% !important; }
.text-center { text-align: center !important; }
.text-muted { color: #6c757d !important; }
.text-small { font-size: 80%; }
.row { display: flex; flex-wrap: wrap; margin: 0 -15px; }
[class*="col-md-"] { position: relative; width: 100%; padding: 0 15px; }
@media (min-width: 768px) {
.col-md-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-md-3 { flex: 0 0 25%; max-width: 25%; }
.col-md-6 { flex: 0 0 50%; max-width: 50%; }
.col-md-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-md-12 { flex: 0 0 100%; max-width: 100%; }
}
h1 { font-size: 2.5rem; margin-bottom: .5rem; font-weight: 500; }
h4 { font-size: 1.5rem; margin-bottom: .5rem; font-weight: 500; }
label { display: inline-block; margin-bottom: .5rem; }
.form-group { margin-bottom: 1rem; }
.form-text { display: block; margin-top: .25rem; }
.form-control, .custom-select {
display: block; width: 100%; height: calc(1.5em + .75rem + 2px);
padding: .375rem .75rem; font-size: 1rem; line-height: 1.5; color: #495057;
background-color: #fff; border: 1px solid #ced4da; border-radius: .25rem;
}
.form-control:focus, .custom-select:focus { border-color: #80bdff; outline: 0; box-shadow: 0 0 0 .2rem rgba(0,123,255,.25); }
.btn { display: inline-block; font-weight: 400; text-align: center; border: 1px solid transparent; padding: .375rem .75rem; font-size: 1rem; line-height: 1.5; border-radius: .25rem; cursor: pointer; text-decoration: none; }
.btn-lg { padding: .5rem 1rem; font-size: 1.25rem; border-radius: .3rem; }
.btn-block { display: block; width: 100%; }
.btn-success { color: #fff; background-color: #28a745; border-color: #28a745; }
.btn-primary { color: #fff; background-color: #007bff; border-color: #007bff; }
.btn-secondary { color: #fff; background-color: #6c757d; border-color: #6c757d; }
.alert { padding: .75rem 1.25rem; margin-bottom: 1rem; border: 1px solid transparent; border-radius: .25rem; }
.alert-danger { color: #721c24; background-color: #f8d7da; border-color: #f5c6cb; }
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

+193
View File
@@ -0,0 +1,193 @@
/* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* ©2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence,
see documentation or authors website for more details */
function sack(file) {
this.xmlhttp = null;
this.resetData = function() {
this.method = "POST";
this.queryStringSeparator = "?";
this.argumentSeparator = "&";
this.URLString = "";
this.encodeURIString = true;
this.execute = false;
this.element = null;
this.elementObj = null;
this.requestFile = file;
this.vars = new Object();
this.responseStatus = new Array(2);
};
this.resetFunctions = function() {
this.onLoading = function() { };
this.onLoaded = function() { };
this.onInteractive = function() { };
this.onCompletion = function() { };
this.onError = function() { };
this.onFail = function() { };
};
this.reset = function() {
this.resetFunctions();
this.resetData();
};
this.createAJAX = function() {
try {
this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e1) {
try {
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
this.xmlhttp = null;
}
}
if (! this.xmlhttp) {
if (typeof XMLHttpRequest != "undefined") {
this.xmlhttp = new XMLHttpRequest();
} else {
this.failed = true;
}
}
};
this.setVar = function(name, value){
this.vars[name] = Array(value, false);
};
this.encVar = function(name, value, returnvars) {
if (true == returnvars) {
return Array(encodeURIComponent(name), encodeURIComponent(value));
} else {
this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
}
}
this.processURLString = function(string, encode) {
encoded = encodeURIComponent(this.argumentSeparator);
regexp = new RegExp(this.argumentSeparator + "|" + encoded);
varArray = string.split(regexp);
for (i = 0; i < varArray.length; i++){
urlVars = varArray[i].split("=");
if (true == encode){
this.encVar(urlVars[0], urlVars[1]);
} else {
this.setVar(urlVars[0], urlVars[1]);
}
}
}
this.createURLString = function(urlstring) {
if (this.encodeURIString && this.URLString.length) {
this.processURLString(this.URLString, true);
}
if (urlstring) {
if (this.URLString.length) {
this.URLString += this.argumentSeparator + urlstring;
} else {
this.URLString = urlstring;
}
}
// prevents caching of URLString
this.setVar("rndval", new Date().getTime());
urlstringtemp = new Array();
for (key in this.vars) {
if (false == this.vars[key][1] && true == this.encodeURIString) {
encoded = this.encVar(key, this.vars[key][0], true);
delete this.vars[key];
this.vars[encoded[0]] = Array(encoded[1], true);
key = encoded[0];
}
urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
}
if (urlstring){
this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
} else {
this.URLString += urlstringtemp.join(this.argumentSeparator);
}
}
this.runResponse = function() {
eval(this.response);
}
this.runAJAX = function(urlstring) {
if (this.failed) {
this.onFail();
} else {
this.createURLString(urlstring);
if (this.element) {
this.elementObj = document.getElementById(this.element);
}
if (this.xmlhttp) {
var self = this;
if (this.method == "GET") {
totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
this.xmlhttp.open(this.method, totalurlstring, true);
} else {
this.xmlhttp.open(this.method, this.requestFile, true);
try {
this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
} catch (e) { }
}
this.xmlhttp.onreadystatechange = function() {
switch (self.xmlhttp.readyState) {
case 1:
self.onLoading();
break;
case 2:
self.onLoaded();
break;
case 3:
self.onInteractive();
break;
case 4:
self.response = self.xmlhttp.responseText;
self.responseXML = self.xmlhttp.responseXML;
self.responseStatus[0] = self.xmlhttp.status;
self.responseStatus[1] = self.xmlhttp.statusText;
if (self.execute) {
self.runResponse();
}
if (self.elementObj) {
elemNodeName = self.elementObj.nodeName;
elemNodeName.toLowerCase();
if (elemNodeName == "input"
|| elemNodeName == "select"
|| elemNodeName == "option"
|| elemNodeName == "textarea") {
self.elementObj.value = self.response;
} else {
self.elementObj.innerHTML = self.response;
}
}
if (self.responseStatus[0] == "200") {
self.onCompletion();
} else {
self.onError();
}
self.URLString = "";
break;
}
};
this.xmlhttp.send(this.URLString);
}
}
};
this.reset();
this.createAJAX();
}
+16
View File
@@ -0,0 +1,16 @@
.dmh-modal-overlay {
position: fixed; inset: 0; background: rgba(0,0,0,0.45);
display: flex; align-items: center; justify-content: center; z-index: 10000;
}
.dmh-modal-box {
background: #fff; padding: 20px 24px; border-radius: 6px;
max-width: 380px; width: 90%; box-shadow: 0 6px 24px rgba(0,0,0,0.25);
text-align: center;
}
.dmh-modal-msg { margin: 0 0 16px; font-size: 16px; color: #222; }
.dmh-modal-actions { display: flex; justify-content: center; gap: 12px; }
.dmh-modal-btn {
padding: 6px 18px; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;
}
.dmh-modal-ok { background: #28a745; color: #fff; }
.dmh-modal-cancel { background: #6c757d; color: #fff; }
+49
View File
@@ -0,0 +1,49 @@
/* Lightweight $.alert and $.confirm modal implementation */
(function($) {
if (!$) return;
function showModal(message, isConfirm, callback) {
var overlay = document.createElement("div");
overlay.className = "dmh-modal-overlay";
var box = document.createElement("div");
box.className = "dmh-modal-box";
var msgEl = document.createElement("p");
msgEl.className = "dmh-modal-msg";
msgEl.textContent = message;
box.appendChild(msgEl);
var actions = document.createElement("div");
actions.className = "dmh-modal-actions";
var okBtn = document.createElement("button");
okBtn.type = "button";
okBtn.className = "dmh-modal-btn dmh-modal-ok";
okBtn.textContent = "OK";
okBtn.onclick = function() {
document.body.removeChild(overlay);
if (callback) callback(true);
};
actions.appendChild(okBtn);
if (isConfirm) {
var cancelBtn = document.createElement("button");
cancelBtn.type = "button";
cancelBtn.className = "dmh-modal-btn dmh-modal-cancel";
cancelBtn.textContent = "Cancel";
cancelBtn.onclick = function() {
document.body.removeChild(overlay);
if (callback) callback(false);
};
actions.appendChild(cancelBtn);
}
box.appendChild(actions);
overlay.appendChild(box);
document.body.appendChild(overlay);
okBtn.focus();
}
$.alert = function(msg) { showModal(msg, false, null); };
$.confirm = function(msg, cb) { showModal(msg, true, cb); };
})(window.$);
+47
View File
@@ -0,0 +1,47 @@
/* Lightweight canvas image upload resizer plugin */
(function($) {
if (!$ || !$.fn) return;
$.fn.imageUploadResizer = function(options) {
options = options || {};
var maxW = options.max_width || 1000;
var maxH = options.max_height || 1000;
var quality = options.quality || 0.8;
var skip = options.do_not_resize || [];
this.els.forEach(function(input) {
input.addEventListener("change", function(event) {
var file = event.target.files && event.target.files[0];
if (!file) return;
if (input.id === "ptnPhoto" && typeof window.loadFile === "function") {
window.loadFile(event);
}
var ext = (file.name.split(".").pop() || "").toLowerCase();
if (skip.indexOf(ext) !== -1 || file.type.indexOf("image/") !== 0) return;
var reader = new FileReader();
reader.onload = function(e) {
var img = new Image();
img.onload = function() {
var w = img.width, h = img.height;
if (w <= maxW && h <= maxH) return;
var ratio = Math.min(maxW / w, maxH / h);
var canvas = document.createElement("canvas");
canvas.width = Math.round(w * ratio);
canvas.height = Math.round(h * ratio);
canvas.getContext("2d").drawImage(img, 0, 0, canvas.width, canvas.height);
canvas.toBlob(function(blob) {
if (!blob || typeof DataTransfer === "undefined") return;
var resized = new File([blob], file.name, { type: file.type || "image/jpeg" });
var dt = new DataTransfer();
dt.items.add(resized);
input.files = dt.files;
}, file.type || "image/jpeg", quality);
};
img.src = e.target.result;
};
reader.readAsDataURL(file);
});
});
return this;
};
})(window.jQuery || window.$);
+5
View File
@@ -0,0 +1,5 @@
/* Local jQuery alias for imageUploadResizer noConflict block */
(function(global) {
if (!global.jQuery) return;
global.$ = global.jQuery;
})(window);
+512
View File
@@ -0,0 +1,512 @@
// JavaScript Document
String.prototype.trim = function()
{
return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function()
{
return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function()
{
return this.replace(/\s+$/,"");
}
function stopRKey(evt)
{
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) { getClientData(); return false; }
}
document.onkeypress = stopRKey;
var ajax = new sack();
function getState(country,state,other_state,city,other_city)
{
document.getElementById("citydiv").innerHTML="<select class='custom-select d-block w-100' name='other_city' id='other_city'><option value=''>-- Select --</option></select>";
ajax.requestFile = 'getState.php?countryId='+country+'&stateId='+state+'&other_state='+other_state+'&cityId='+city+'&other_city='+other_city;
ajax.onCompletion = showState;
ajax.runAJAX();
getCity(country,state,other_state,city,other_city);
}
function showState()
{
document.getElementById("statediv").innerHTML=ajax.response;
}
var ajax1 = new sack();
function getCity(country,state,other_state,city,other_city)
{
ajax1.requestFile = 'getCity.php?countryId='+country+'&stateId='+state+'&other_state='+other_state+'&cityId='+city+'&other_city='+other_city;
ajax1.onCompletion = showCity;
ajax1.runAJAX();
}
function showCity()
{
document.getElementById("citydiv").innerHTML=ajax1.response
}
var ajax3 = new sack();
function p_getState(country,state,other_state,city,other_city)
{
document.getElementById("p_citydiv").innerHTML="<select class='custom-select d-block w-100' name='p_city' id='p_city'><option value=''>-- Select --</option></select>";
ajax3.requestFile = 'p_getState.php?countryId='+country+'&stateId='+state+'&other_state='+other_state+'&cityId='+city+'&other_city='+other_city;
ajax3.onCompletion = p_showState;
ajax3.runAJAX();
p_getCity(country,state,other_state,city,other_city);
}
function p_showState()
{
document.getElementById("p_statediv").innerHTML=ajax3.response;
}
var ajax4 = new sack();
function p_getCity(country,state,other_state,city,other_city)
{
ajax4.requestFile = 'p_getCity.php?countryId='+country+'&stateId='+state+'&other_state='+other_state+'&cityId='+city+'&other_city='+other_city;
ajax4.onCompletion = p_showCity;
ajax4.runAJAX();
}
function p_showCity()
{
document.getElementById("p_citydiv").innerHTML=ajax4.response
}
function setDOB()
{
var age = document.getElementById("age").value;
var e = document.getElementById("ageUnit");
var ageUnit = e.options[e.selectedIndex].value;
if(ageUnit == 0) {
ageUnit = "years";
} else if(ageUnit == 1) {
ageUnit = "months";
} else if(ageUnit == 2) {
ageUnit = "days";
} else if(ageUnit == 3) {
ageUnit = "weeks";
}
age= parseInt(age);
if(age <= 0 || isNaN(age) )
{
$.alert("Patient age should be greater than zero.");
document.getElementById("age").value = '';
return false;
}
if( age >= 100 && ageUnit == "years" )
{
var confirmStatus = confirm("Patient's age is more than 100 Years. Do you want to proceed?");
if(confirmStatus == false)
{
document.getElementById("age").value = '';
return false;
}
}
var ajaxDOB = new sack();
ajaxDOB.requestFile = 'getDOB.php?age='+age+'&ageUnit='+ageUnit;
ajaxDOB.onCompletion = showDOB;
ajaxDOB.runAJAX();
function showDOB()
{
document.getElementById("dob").value=ajaxDOB.response;
document.getElementById("approx_dob").value = 1;
}
}
function validateForm(e, docum)
{
if(docum.title.value.trim() == '')
{
//alert("Please Select Title");
$.alert('Please Select Title');
docum.title.focus();
return false;
}
if(docum.lname.value.trim() == '')
{
$.alert("Please Enter Last Name");
docum.lname.select();
docum.lname.focus();
return false;
}
if(docum.fname.value.trim() == '')
{
$.alert("Please Enter First Name");
docum.fname.select();
docum.fname.focus();
return false;
}
if( docum.pan_no.value.trim() != '' )
{
var panVal = docum.pan_no.value.trim();
var regpan = /^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$/;
if(regpan.test(panVal))
{
//return true;
} else {
$.alert("Enter Valid Pan Card Number");
return false;
}
}
if(docum.aadhar_no.value.trim() != '')
{
if( isNaN(docum.aadhar_no.value.trim()) )
{
$.alert("Please Enter Numbers In Aadhar Number");
docum.aadhar_no.select();
docum.aadhar_no.focus();
return false;
} else {
var adhr = docum.aadhar_no.value.trim();
if(adhr.length < 12)
{
$.alert("Please Enter 12 Digit Aadhar Number");
docum.aadhar_no.select();
docum.aadhar_no.focus();
return false;
}
}
}
if( docum.dob.value.trim() == '' || docum.age.value.trim() == '' )
{
$.alert("Please Enter Date Of Birth Or Age.");
return false;
}
if( docum.gender.value.trim() == 2 )
{
if( docum.marital_status.value.trim() == '' )
{
$.alert("Please Choose Marital Status.");
return false;
}
if( docum.marital_status.value.trim() != 'Single' )
{
if( docum.dom.value.trim() == '' )
{
$.alert("Please Enter Date Of Marriage.");
return false;
}
if( docum.bmname.value.trim() == '' )
{
$.alert("Please Enter Before Marriage Name.");
return false;
}
}
}
if(docum.patient_income.value.trim() != '')
{
if( isNaN(docum.patient_income.value.trim()) )
{
$.alert("Please Enter Numbers In Monthly Income");
docum.patient_income.select();
docum.patient_income.focus();
return false;
}
}
if(docum.address1.value.trim() == '')
{
$.alert("Please Enter House Name/Appt.No Details");
docum.address1.select();
docum.address1.focus();
return false;
}
if(docum.country.value.trim() == '')
{
$.alert("Please Select Country");
docum.country.focus();
return false;
}
var stateField = docum.state || docum.other_state;
if(!stateField || stateField.value.trim() == '')
{
$.alert("Please Select State");
if(stateField) stateField.focus();
return false;
}
var cityField = docum.city || docum.other_city;
if(!cityField || cityField.value.trim() == '')
{
$.alert("Please Select City");
if(cityField) cityField.focus();
return false;
}
if(docum.pincode.value.trim() != '')
{
if( isNaN(docum.pincode.value.trim()) )
{
$.alert("Please Enter Numbers In Pin Number");
docum.pincode.select();
docum.pincode.focus();
return false;
}
}
if(docum.cell_phone.value.trim() != '')
{
if( isNaN(docum.cell_phone.value.trim()) )
{
$.alert("Please Enter Numbers In Cell Number");
docum.cell_phone.select();
docum.cell_phone.focus();
return false;
} else {
var adhr1 = docum.cell_phone.value.trim();
if(adhr1.length != 10)
{
$.alert("Please Enter 10 Digit Cell Number");
docum.cell_phone.select();
docum.cell_phone.focus();
return false;
}
}
}
if(docum.email.value.trim() != '')
{
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(docum.email.value.trim()))
{
} else {
$.alert("You have entered an invalid email address!")
return false;
}
}
if(docum.emg_person.value.trim() == '' || docum.emg_person1.value.trim() == '')
{
$.alert("Please Enter Emergency Contact Person");
docum.emg_person.select();
docum.emg_person.focus();
return false;
}
if(docum.relation.value.trim() == '')
{
$.alert("Please Select Relation With Patient");
docum.relation.focus();
return false;
}
if(docum.emg_no.value.trim() == '')
{
$.alert("Please Enter Emergency Contact Number");
docum.emg_no.select();
docum.emg_no.focus();
return false;
}
// ---
if(docum.re_persone.value.trim() == '')
{
$.alert("Please Enter Name Of Representative");
docum.re_persone.select();
docum.re_persone.focus();
return false;
}
if(docum.re_relation.value.trim() == '')
{
$.alert("Please Select Representative Relation To Patient");
docum.re_relation.focus();
return false;
}
if(docum.id_file.value.trim() == '')
{
$.alert("Please Upload Identity Proof");
docum.id_file.focus();
return false;
} else
{
var fileInput = document.getElementById('id_file');
var filePath = fileInput.value;
var allowedExtensions = /(\.jpg|\.jpeg|\.png|\.gif|\.pdf)$/i;
if (!allowedExtensions.exec(filePath)) {
alert('Invalid file type');
fileInput.value = '';
return false;
}
}
if(document.getElementById("txtcaptcha").value.trim()=="")
{
document.getElementById("txtcaptcha").focus();
$.alert("Enter captcha text.");
return false;
}
var mainCaptchaEl = document.getElementById('mainCaptcha');
if(mainCaptchaEl)
{
var string1 = mainCaptchaEl.value.split(' ').join('');
var string2 = document.getElementById('txtcaptcha').value.split(' ').join('');
if(string1 !== string2)
{
document.getElementById('txtcaptcha').value = '';
$.alert("Invalid Captcha Text!");
return false;
}
}
$.confirm('Do you want to save the details..?',function(a){ if( a == true ) {
//document.getElementById("SaveDB").value = 'Save';
document.getElementById("vm").focus();
document.getElementById("vm").select();
document.getElementById("loader").style.display = "block";
document.getElementById("SaveData").style.display = "none";
document.getElementById("form").submit();
} } );
/*if( !confirm('Do you want to save the details..?') )
{
return false;
}*/
document.getElementById("vm").focus();
document.getElementById("vm").select();
return false;
}
function selGender(val)
{
if(val == 1 || val == 10 || val == 14)
document.getElementById("gender").selectedIndex = 1;
else if( val == 16 )
document.getElementById("gender").selectedIndex = 4;
else if( val == 15 )
document.getElementById("gender").selectedIndex = 5;
else if( val == 2 || val == 3 || val == 4 || val == 11 || val == 12 || val == 13 )
document.getElementById("gender").selectedIndex = 2;
else
document.getElementById("gender").selectedIndex = 0;
if( val == 2 || val == 3 || val == 4 || val == 11 || val == 12 || val == 13 )
$("#divMarried1,#divMarried2").show();
else
$("#divMarried1,#divMarried2").hide();
}
//alert(getAge('15/05/2019'));
function getAge(dateString)
{
document.getElementById("approx_dob").value = 0;
var now = new Date();
var today = new Date(now.getYear(),now.getMonth(),now.getDate());
var yearNow = now.getYear();
var monthNow = now.getMonth();
var dateNow = now.getDate();
var tempDate = dateString.split("/");
var y = tempDate[2]; //dateString.substring(6,10);
var m = tempDate[1]-1; //dateString.substring(0,2)-1;
var d = tempDate[0]; //dateString.substring(3,5);
var dob = new Date( y, m, d );
var yearDob = dob.getYear();
var monthDob = dob.getMonth();
var dateDob = dob.getDate();
var age = {};
var ageString = "";
var yearString = "";
var monthString = "";
var dayString = "";
yearAge = yearNow - yearDob;
if (monthNow >= monthDob)
var monthAge = monthNow - monthDob;
else {
yearAge--;
var monthAge = 12 + monthNow -monthDob;
}
if (dateNow >= dateDob)
var dateAge = dateNow - dateDob;
else {
monthAge--;
var dateAge = 31 + dateNow - dateDob;
if (monthAge < 0) {
monthAge = 11;
yearAge--;
}
}
age = { years:yearAge, months:monthAge, days:dateAge };
if ( age.years > 1 ) yearString = " years";
else yearString = " year";
if ( age.months> 1 ) monthString = " months";
else monthString = " month";
if ( age.days > 1 ) dayString = " days";
else dayString = " day";
if ( (age.years > 0) && (age.months > 0) && (age.days > 0) )
{ document.getElementById('age').value = age.years; document.getElementById("ageUnit").selectedIndex = 0; }
else if ( (age.years == 0) && (age.months == 0) && (age.days > 0) )
{ document.getElementById('age').value = age.days; document.getElementById("ageUnit").selectedIndex = 2; }
else if ( (age.years > 0) && (age.months == 0) && (age.days == 0) )
{ document.getElementById('age').value = age.years; document.getElementById("ageUnit").selectedIndex = 0; }
else if ( (age.years > 0) && (age.months > 0) && (age.days == 0) )
{ document.getElementById('age').value = age.years; document.getElementById("ageUnit").selectedIndex = 0; }
else if ( (age.years == 0) && (age.months > 0) && (age.days > 0) )
{ document.getElementById('age').value = age.months; document.getElementById("ageUnit").selectedIndex = 1; }
else if ( (age.years > 0) && (age.months == 0) && (age.days > 0) )
{ document.getElementById('age').value = age.years; document.getElementById("ageUnit").selectedIndex = 0; }
else if ( (age.years == 0) && (age.months > 0) && (age.days == 0) )
{ document.getElementById('age').value = age.months; document.getElementById("ageUnit").selectedIndex = 1; }
else ageString = "Oops! Could not calculate age!";
return ageString;
}
function FillBilling(f)
{
if(f.copy.checked == true)
{
f.p_address1.value = f.address1.value;
f.p_address2.value = f.address2.value;
f.p_post_office.value = f.post_office.value;
f.p_pincode.value = f.pincode.value;
f.p_phone.value = f.phone.value;
$('#p_country').html($('#country').html());
f.p_country.value = f.country.value;
if(document.getElementById("country").value == 38)
{
document.getElementById("p_statediv").innerHTML = "<select class='custom-select d-block w-100' name='p_state' id='p_state' onchange=p_getCity('',this.value,'','','');></select>";
document.getElementById("p_citydiv").innerHTML = "<select class='custom-select d-block w-100' name='p_city' id='p_city'></select>";
$('#p_state').html($('#state').html());
$('#p_city').html($('#city').html());
f.p_state.value = f.state.value;
f.p_city.value = f.city.value;
} else
{
p_getState(f.country.value, '', f.other_state.value, '', f.other_city.value);
}
} else {
f.p_address1.value = '';
f.p_address2.value = '';
f.p_post_office.value = '';
f.p_pincode.value = '';
f.p_phone.value = '';
f.p_country.value = '38';
p_getState('38', '', '', '', '');
}
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB