function Toggle(item) {
obj=document.getElementById(item);
//alert(item);
visible=(obj.style.display!="none");
key=document.getElementById("x" + item);
//alert(obj);
if (visible) {
obj.style.display="none";
key.innerHTML="<img src='images/sidearrow1.gif'  hspace='0' vspace='0' border='0'>";
} 

else {
// alert("fd");
obj.style.display="block";
key.innerHTML="<img src='images/downarrow1.gif'  hspace='0' vspace='0' border='0'>";
}
}





function Expand() {
divs=document.getElementsByTagName("DIV");
for (i=0;i<divs.length;i++) {
    divs[i].style.display="block";
    key=document.getElementById("x" + divs[i].id);
    key.innerHTML="<img src='collapse.gif'  hspace='0' vspace='0' border='0'>";
}
}


















function Collapse() {
divs=document.getElementsByTagName("DIV");
for (i=0;i<divs.length;i++) {
    divs[i].style.display="none";
    key=document.getElementById("x" + divs[i].id);

    key.innerHTML="<img src='collapse.gif'  hspace='0' vspace='0' border='0'>";
}
}



<!--------------------------- validations javascript---------------------------------->

function checkFormselect()
{
if(document.selectFriend.fList.value=="")
{
alert("Please Select the recipient's name")
document.selectFriend.fList.focus()
return false
}
return true
}	

function isDigit(c) { return ((c>="0") && (c<="9")) }
function isEmpty(s) { return ((s==null) || (s.length = 0) ) }
function UserFeedback(oFormEle) 
{
oFormEle.focus();
}
var whitespace="\t\r\n";

function isWhitespace(s)   		//	checking for blank space
{
var i;
if(isEmpty(s)) return true;
for(i=0;i<s.length;i++)
{  
var c = s.charAt(i);
if (whitespace.indexOf(c) == -1) return false;
}
return true;
}
/*	function isSpace(s,message)
{
var i,ss,len;
ss=s.value;
len=0;

for(i=0;i<ss.length;i++)
{
var c = ss.charAt(i);
if (c==" ") len=len + 1;
} 
if (len == ss.length )
{ UserFeedback(s);
s.value = ""
alert(message);
return false;
}
return true;
}*/

function isSpace(s,message)
{
ss=s.value; 
var length=ss.length;
var c = ss.charAt(0);
var d=ss.charAt(length-1);
//    var regexpr =/[A-Za-z0-9]/;
//     result= regexpr.test(c)
//	if (!result) 
if(c==" "||d==" ")
{
UserFeedback(s);
s.value = ""
alert(message);
return false; 
}
return true;
}



<!----is Amount--------------------------------- -->

function isAmount(ofrm,mess){ 

var bn=ofrm.value;

var length=bn.length;

for(i=0;i< bn.length;i++){                      
var c=bn.charAt(i);

if(i==0){

if(isDigit(c)){   }  
else{alert(mess); ofrm.value=""; ofrm.focus(); return false; }
}


if((i==length-1)){

if(isDigit(c)){}
else{alert(mess) ;ofrm.value=""; ofrm.focus(); return false; }
}

else{


if(isDigit(c)||c=='.'||c==','){

}
else{alert(mess); ofrm.value=""; ofrm.focus(); return false; }

}

}
return true; 
}

<!-------End Of is Action-------------------------- -->

<!----Check Selection------------------------------- -->   

function CheckSelection()
{
var checked = 0;
for(i=0;i<document.branchdet.elements.length;i++)
{
if(document.branchdet.elements[i].name.indexOf("organtypes")>-1)
{
if(document.branchdet.elements[i].checked == true)
{
var checked = 1;
}
}
}
if(checked == 0)
{
alert("Please Select atleast one checkbox");
return false;
}
else
{
//alert("Thanks for Selecting Check Box");
return false;
}
}



function checksel(selection,msg)
{
var checkSelected = false;
for (i = 0;  i < selection.length;  i++)
{
if (selection[i].checked)
checkSelected = true;
}
if (!checkSelected)
{
alert("Please select at least one of the \"Test Checkbox\" options.");
return (false);
}


var checkCounter = 0;
for (i = 0;  i < selection.length;  i++)
{
if (selection[i].checked)
checkCounter = checkCounter + 1;
}


return true;
}

function onechecksel(selection,msg)
{
var checkSelected=0;
alert(selection.length);

for (i = 0;  i < selection.length;  i++)
{
if (selection[i].checked)
checkSelected = (checkSelected*1)+1;;
}
alert(checkSelected);
if (checkSelected==0)
{
alert("Please select at least one of the \"Test Checkbox\" options.");
return (false);
}else{


return true;}
}

<!------------------------------ Multipul Items Checking  -->

function MultiSelection(theForm,msg) {
var numSelected = 0;
var i;
for (i = 0;  i < theForm.length;  i++)
{
if (theForm.options[i].selected)
numSelected++;
}

/*if (numSelected > 5)
{
alert("Please select at most 5 of the options.");
theForm.focus();
return (false);
}*/

if (numSelected < 1)
{
alert(msg);
theForm.focus();
return (false);
}
return(true);
}


<!----Force entry------------------------------- -->        

function ForceEntry(val,str)
{  

var name=val.value;
var string_input=new String(name);
/*if(string_input.length > size)
{
alert("please enter minimum number of characters");
val.focus();
return(false);
}*/
if (isWhitespace(string_input))
{ alert(str);
val.focus();
return(false);
}
else {return(true);}
}	


<!----Checking for Date of Birth------------------------------- -->       

function DobCal(dob,str)
{   
var userdate=dob.value; 
var arr1 = userdate.split("-");
//alert(arr1[0]);
var dt1 = new Date();  
dt1.setFullYear(arr1[2],arr1[0]-1,arr1[1]);
var d = new Date();  
var days=days_between(d,dt1); 
function days_between(date1,date2) {  
// The number of milliseconds in one day  
var ONE_DAY = 1000 * 60 * 60 * 24; 
// Convert both dates to milliseconds  
var date1_ms = date1.getTime(); 
var date2_ms = date2.getTime();   
// Calculate the difference in milliseconds 
var difference_ms =date1_ms - date2_ms;  
// Convert back to days and return 
return Math.round(difference_ms/ONE_DAY); 
}   
var years=days/365;  
if(days<0)
{
alert(str);
dob.value="";
dob.focus();
return(false);
}
else{
return(true);
}
}
<!----Checking for Expiry Date------------------------------- -->  

function ExpDate(expdt,str)
{

var userdate = expdt.value;

var arr1 = userdate.split("-");  
var dt1 = new Date();  
dt1.setFullYear(arr1[2],arr1[1]-1,arr1[0]);
var d = new Date();  
var days=days_between(d,dt1); 
function days_between(date1,date2) {  
// The number of milliseconds in one day  
var ONE_DAY = 1000 * 60 * 60 * 24; 
// Convert both dates to milliseconds  
var date1_ms = date1.getTime(); 
var date2_ms = date2.getTime();   
// Calculate the difference in milliseconds 
var difference_ms =date1_ms - date2_ms;  
// Convert back to days and return 
return Math.round(difference_ms/ONE_DAY); 
}   
var years=days/365;  
if(days>0)
{
alert(str);
expdt.value="";
expdt.focus();
return(false);
}
else{
return(true);
}
}


/*function isString(oFormEle,msg)
{
var n = oFormEle.value;
alert("isstring");
for(i=0;i<n.length;i++)
{
var c = n.charAt(i);
if (c =="") {                                  
}
else if(isDigit(c))
{
UserFeedback(oFormEle);
oFormEle.value = ""
alert(msg);
return false;
}
}
return true;
}  */ 

<!----Only Alphabets Are Allowed------------------------------- -->  

function validateAlpha( oform, mesg ) {
var text=oform.value;
for ( c=0; c < text.length; c ++ ) {
alpha = ( text.charCodeAt ( c ) >= 65 &&
text.charCodeAt ( c ) <=90 ) || 
( text.charCodeAt ( c ) >= 97 &&
text.charCodeAt ( c ) <=122 )
if (alpha ) {

}else{
alert ( mesg );   
oform.value=""; 
oform.focus();
return false;
}
}
return true;
}

function isString(s,mesg)
{
ss=s.value;  
var regexpr =/[A-Za-z]/;   
for(i=0;i<ss.length;i++)
{ 
var c = ss.charAt(i);   
result= regexpr.test(c)
if (result || c==" ") 
{}
else{
s.value="";
alert(mesg);
s.focus();
return false;
} 
}   

return true;
} 

function multiSearch(s,mesg)
{
ss=s.value;  
var regexpr =/[A-Za-z0-9]/;   
for(i=0;i<ss.length;i++)
{ 
var c = ss.charAt(i);   
result= regexpr.test(c)
if (result || c==" " || c=="*") 
{}
else{
s.value="";
alert(mesg);
s.focus();
return false;
} 
}   

return true;
} 


function isEmail(oFormEle,msg) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var email = oFormEle.value;
if(reg.test(email) == false) {
oFormEle.value="";
alert(msg);
oFormEle.focus()
return false;
}
return true;
}

function ischecked(oFormEle,msg)
{
var s=oFormEle.value
if (s=="na"){
alert(msg); 
oFormEle.focus()
return false;
}
return true;
}	


function isNumeric(oFormEle,msg)
{

var sValue=oFormEle.value;

if(isNaN(sValue) == true){
oFormEle.value="";
alert(msg);

oFormEle.focus()
return false;
} 
return true;
}


function isMin(oFormEle,msg,minlen) {

var sValue=oFormEle.value;
var strl=sValue.length;




if(strl < minlen) {
oFormEle.value=""; 
alert(msg+" "+minlen);
oFormEle.focus();
return false
}
return true;
}

<!----Checking for Password(should contain atleast one digit)------------------------------- -->              

function isStrongPassword(opass,msg) 
{

// var control = document.opass.password;
var myString= opass.value; 
//var pwdsstr=myString.substring(0,1);
var Stringlen = myString.length;
var ValidateDigits = /[^0-9]/g;
var ValidateSpChar = /[a-zA-Z0-9]/g;
var ValidateChar = /[^A-Z]/g;

var digitString = myString.replace(ValidateDigits , "");
//var specialString = myString.replace(ValidateSpChar, "");
var charString = myString.replace(ValidateChar, "");


if(digitString < 1)
{
alert("Passwords must include at least 1 numeric characters");
opass.value="";
opass.focus();
return false;
}

return true;
} 

function pwdCapsCheck(pwdpass,msg)
{
var myString= pwdpass.value; 
var pwdsstr=myString.substring(0,1);
var ValidateChar = /[^A-Z]/g;
if(ValidateChar.test(pwdsstr) == true) {
alert(msg);
pwdpass.value="";
pwdpass.focus();
return false;
}
return true;
}

function checkForm(radbut,msg) 
{  
var checked = false;
for (var i=0; i< radbut.length; i++)    
{    
if (radbut[i].checked)
{     
checked = true;    
break;     
}   
}   
if(!checked)     
alert(msg);  
return checked ;
}


<!---------------------Alfa Numeric,Not Numeric,First Special Char------------------------>

<!-------------- Not Only Alphabets ---------->

function isString1(s){
var ss=s.value;  
var count=0;
var regexpr =/[A-Za-z]/;   
for(i=0;i< ss.length;i++){ 
var c = ss.charAt(i);   
result=regexpr.test(c);
if (result){
count=count+1;
}
} 
if(count==ss.length){
return true;
}else{
return false;
}
} 

function isNotString(ofrm,message){         
if(isString1(ofrm)){
alert(message); ofrm.value=""; ofrm.focus(); return false;
}
return true;
}


<!------------ Not Only Numeric -------------->

function isNum(oFormEle){  
var sValue=oFormEle.value;
var count=0;
var numbers =/[0-9]/;
var c=sValue.charAt(0);   
if(numbers.test(c)){
count=count+1;
for(i=1;i< sValue.length;i++){
c = sValue.charAt(i);   
if (numbers.test(c) || special.indexOf(c)!=-1){
count=count+1;
}
} 
}
if(count==sValue.length){	  
return true;
}else{
return false;
}
}


function onlyNum(oFormEle,message){
var sValue=oFormEle.value;
var count=0;
var numbers =/[0-9]/;
for(i=0;i< sValue.length;i++){
var c = sValue[i];
result= numbers.test(c);
if (result){
count=count+1;
}
} 
if(count==sValue.length){	  
return true;
}else{
alert(message);
oFormEle.focus();
oFormEle.value="";
return false;
}
}

function isNotNumeric(ofrm,message){
if(isNum(ofrm)){
alert(message); ofrm.value=""; ofrm.focus(); return false;
}
return true;
}
<!--------------  Checking Drug Licence No Contain Atleast One Numberic ------------------->

function druglicensecheck(opass,msg) 
{

// var control = document.opass.password;
var myString= opass.value; 
//var pwdsstr=myString.substring(0,1);
var Stringlen = myString.length;
var ValidateDigits = /[^0-9]/g;
var ValidateSpChar = /[a-zA-Z0-9]/g;
var ValidateChar = /[^A-Z]/g;

var digitString = myString.replace(ValidateDigits , "");
//var specialString = myString.replace(ValidateSpChar, "");
var charString = myString.replace(ValidateChar, "");


if(digitString < 1)
{
alert("DrugLicense must include at least 1 numeric characters");
opass.value="";
opass.focus();
return false;
}

return true;
} 



<!------------- Alpha Numeric ---------------->

function isAlpha(a){        
var alphabets="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (alphabets.indexOf(a) == -1){ return false;} 
return true;
}

function isAlphaNum(ofrm,message){        
var bi=ofrm.value;
var count1=0;
var length=bi.length;       
for(i=0;i< bi.length;i++)
{  
var c = bi.charAt(i);
if(isDigit(c)||isAlpha(c)){ count1=count1+1;}   
}
if(count1!=length){  alert(message); ofrm.value=""; ofrm.focus(); return false;}
return true;
}


<!------------- Special Chars ----------------> 

var special="`~!@#$%^&*()_+-={}[]:\";'\<\>,.\\|?/";                     
function isSpecialChars(ofrm,message){         
var bn=ofrm.value;
var c = bn.charAt(0);
if (special.indexOf(c)==-1) { }
else{         
alert(message); ofrm.value=""; ofrm.focus(); return false; 
}
return true; 
}

function isSpecialChar(ofrm,message){         
var frm=ofrm.value; 
for(i=0;i < frm.length;i++) {
if (special.indexOf(frm.charAt(i))==-1) { }
else{         
alert(message); ofrm.value=""; ofrm.focus(); return false; 
}
}
return true; 
}

function isLastSpecialChar(ofrm,message){ 
var bn=ofrm.value;
var c = bn.charAt(bn.length-1);
if (special.indexOf(c)==-1) { }
else{         
alert(message); ofrm.value=""; ofrm.focus(); return false; 
}
return true; 
}

function isNotZero(ofrm,message){
var bn=ofrm.value;
var count=0;
for(i=0;i < bn.length;i++){
var c = bn.charAt(i);
if (c==0) { count=count+1;}
}
if(count==bn.length){
alert(message); ofrm.value=""; ofrm.focus(); return false; 
}
return true; 
}

function isPhone(ofrm,message){

var bn=ofrm.value;
var length=bn.length;
if(length==1){
var c=bn.charAt(0);
if(isDigit(c)){
}else{
alert(message); ofrm.value=""; ofrm.focus(); return false;
}
}else{
for(i=0;i< bn.length;i++){
var c=bn.charAt(i);
if(i==0){

if(isDigit(c)||c==" "||c=='+'){}
else{alert("Alpha Numerics and Special Characters are not allowed"); ofrm.value=""; ofrm.focus(); return false; }
}
else if(i==length-1){
if(isDigit(c)||c==" "){}
else{alert("Last character should not be a Special Character"); ofrm.value=""; ofrm.focus(); return false; }
}
else{
if(isDigit(c)||c==" "||c=='-'){}
else{alert(message); ofrm.value=""; ofrm.focus(); return false; }
}
}
}
return true;
}



function isZip1(ofrm,message){

var bn=ofrm.value;
var length=bn.length;
if(length==1){
var c=bn.charAt(0);
if(isDigit(c)){
}else{
alert("Not a Valid Zip/Pin Code"); ofrm.value=""; ofrm.focus(); return false;
}
}else{
for(i=0;i< bn.length;i++){
var c=bn.charAt(i);
if(i==0){

if(isDigit(c)||c==" "||c=='+'){}
else{alert("Please Enter Valid Zip/pin code"); ofrm.value=""; ofrm.focus(); return false; }
}
else if(i==length-1){
if(isDigit(c)||c==" "){}
else{alert("Last digit should not be a Special Character");ofrm.focus(); ofrm.value="";  return false; }
}
else{
if(isDigit(c)||c==" "||c=='-'){}
else{alert(message); ofrm.value=""; ofrm.focus(); return false; }
}
}
}
return true;
} 
function isZip(ofrm,message){
var s=ofrm.value;

if(s.length<5)
{
//var reZip = /(^\d{5}$)|(^\d{5}-\d{4}$)/;

// if (!reZip.test(s)) {
alert("Zip Code Is Not Valid");
ofrm.value="";
ofrm.focus();
return false;

}
return true;
}
function isPhone1(ofrm,message){
var s=ofrm.value;
var reZip = /^\(?\d{3}\)?\s|-\d{3}-\d{4}$/;

if (!reZip.test(s)) {
alert('Invalid Phone No: Must be  in the form NNN-NNN-NNNN.');
ofrm.value="";
ofrm.focus();
return false;

}
return true;
}
<!---------------------Url Validation---------------------->

function Urlvalidation(oForm,msg) {


var reg=/^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
var address = oForm.value;
if(reg.test(address) == false) {
oForm.value="";
alert(msg);
oForm.focus()
return false;
}
return true;
}
<!-------------------------------Url Validation END-------------------->

//  ----Phone number Validation----

var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10; 

function stripCharsInBag(s, bag)
{   var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++)
{   
// Check that current character isn't whitespace.
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}


function checkInternationalPhone(strPhone){ 
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (!isNaN(s) && s.length >= minDigitsInIPhoneNumber);
}

function isPhonenumber(Phone,mesg){ 
if ((Phone.value!=null)&&(Phone.value!="")){
if (checkInternationalPhone(Phone.value)==false){
Phone.value="";
alert(msg);
Phone.value="";
Phone.focus();
return false;
}

return true;
}
}





function changehidden(formname,hname,hvalue) {
// alert("in the ");
//  alert(hname);
str=eval("document."+formname);
str1=eval("document."+formname+"."+hname);
str1.value=hvalue;
//alert(hvalue+"  hi  ");

if(hvalue=="Save") {

bool=formValidate();
}
// alert(hvalue);
if(hvalue=="Search") {

str.submit();
} 

if(hvalue=="reset") {

str.reset();
}


if(hvalue=="Edit") {
bool=editRecSajix(str,'rd');
}

if(hvalue=="Delete") {
bool=delteRecSajix(str,'rd');
}



if(bool) {

str.submit();
}  


}





function editRecSajix(forms,str){

var total = 0  ;
var max=eval("forms."+str+".length");
if (max)
{

for (var idx = 0; idx < max; idx++) {
if (eval("forms."+str+"[" + idx + "].checked") == true) {

total += 1;
}
}
}
else
{
if (eval("forms."+str+".checked") == true)
{
total = 1;
//return true;
}
}

if(total==1) {
return true;
}
if(total == 0) {

alert("Select record to edit");
return false;
}

if(total > 1) {
alert("You can not edit more than one Record");
return false;

}


}

function delteRecSajix(forms,str) {

var total = 0 ;
var max=eval("forms."+str+".length");

if(max){

for (var idx = 0; idx < max; idx++) {
if (eval("forms."+str+"[" + idx + "].checked") == true) {

total += 1;

}
}

}
else {

if(eval("forms."+str+".checked") == true){
total=1;
}
}
if(total == 0) {

alert("Select record to delete");
return false;
}



var r=confirm('Are you sure you want to delete?');
if(r==true){
return true;
}
else{

return false;
}



}


function cancelRecSajix(forms,str){
var total = 0  ;
var max=eval("forms."+str+".length");
if (max)
{
for (var idx = 0; idx < max; idx++) {
if (eval("forms."+str+"[" + idx + "].checked") == true) {
total += 1;
}
}
}
else
{
if (eval("forms."+str+".checked") == true)
{
total = 1;                        
}
}
if(total==1) {
return true;
}
if(total == 0) {
alert("Select record to Cancel");
return false;
}
if(total > 1) {
alert("You can not Cancel more than one Record at a Time");
return false;
}
}

function updateRecSajix(forms,str){
var total = 0  ;
var max=eval("forms."+str+".length");
if (max)
{
for (var idx = 0; idx < max; idx++) {
if (eval("forms."+str+"[" + idx + "].checked") == true) {
total += 1;
}
}
}
else
{
if (eval("forms."+str+".checked") == true)
{
total = 1;                        
}
}
if(total==1) {
return true;
}
if(total == 0) {
alert("Select record to Update");
return false;
}
if(total > 1) {
alert("You can not Update more than one Record at a Time");
return false;
}
}

function deleteRecSajix(forms,str){
var total = 0  ;
var max=eval("forms."+str+".length");
if (max)
{
for (var idx = 0; idx < max; idx++) {
if (eval("forms."+str+"[" + idx + "].checked") == true) {
total += 1;
}
}
}
else
{
if (eval("forms."+str+".checked") == true)
{
total = 1;                        
}
}
if(total==1) {
return true;
}
if(total == 0) {
alert("Select record to Delete");
return false;
}                
}

function assignRecSajix(forms,str){
var total = 0  ;
var max=eval("forms."+str+".length");
if (max)
{
for (var idx = 0; idx < max; idx++) {
if (eval("forms."+str+"[" + idx + "].checked") == true) {
total += 1;
}
}
}
else
{
if (eval("forms."+str+".checked") == true)
{
total = 1;                        
}
}
if(total==1) {
return true;
}
if(total == 0) {
alert("Select record to Assign");
return false;
}                
}

function checkRecSajix(forms,str) {

var total = 0 ;
var max=eval("forms."+str+".length");

if(max){

for (var idx = 0; idx < max; idx++) {
if (eval("forms."+str+"[" + idx + "].checked") == true) {

total += 1;

}
}

}
else {

if(eval("forms."+str+".checked") == true){
total=1;
}
}
if(total == 0) {

alert("Select atleast one Record to Assign");
return false;
}


}
function CancelledRecSajix(forms,str) {

var total = 0 ;
var max=eval("forms."+str+".length");

if(max){

for (var idx = 0; idx < max; idx++) {
if (eval("forms."+str+"[" + idx + "].checked") == true) {

total += 1;

}
}

}
else {

if(eval("forms."+str+".checked") == true){
total=1;
}
}
if(total == 0) {

alert("Select atleast one Record to Cancel");
return false;
}


}

<!--------------Records selection  In Grid ---------------->      

function editRecordSajix(forms,str){

var total = 0  ;
var max=eval("forms."+str+".length");
if (max)
{

for (var idx = 0; idx < max; idx++) {
if (eval("forms."+str+"[" + idx + "].checked") == true) {

total += 1;
}
}
}
else
{
if (eval("forms."+str+".checked") == true)
{
total = 1;
}
}


if(total == 0) {

alert("Please Select One record");
return false;
}

if(total > 1) {
alert("You Can Not Select More Than One Record");
return false;

}


}

<!--------------Records Edit And Delete In Grid   END---------------->
<!----------- Date validation During Writing--------------------- -->





<!---------------------- Save as Draft Alert message n redirect to login page ---------------------->

function confirmSubmit()
{
var agree=confirm("Do you want to Save your Registration and go to Login page?");
if (agree)
{
//alert("sddfg");
location.href="./showHome.do";
return true;
}

else
return false ;
}

<!---------------------------Social Security Number validation------------------>

function SSNValidation(m,msg) {

var matchArr = m.match(/^(\d{3})-\d{2}-\d{4}$/);
var numDashes = m.split('-').length - 1;
if (matchArr == null || numDashes == 1) {
m="";
alert('Invalid Social Security No: Must be  in the form NNN-NN-NNNN.');

return false;
}
else 
if (parseInt(matchArr[1],10)==0) {
m="";

alert("Invalid Social Security No: Social Security No's can't start with 000.");

return false;
}
return true;

}
<!-------------------END SSN Validation---------------->
function isValidCreditCardNo(cardno,msg) {
var i=cardno.value;
var matchArr = i.match(/^(\d{4}) ?\d{4} ?\d{4} ?\d{4}$/);
var numDashes = i.split(' ').length - 1;
if (matchArr == null || numDashes == 1) {
cardno.value="";
alert('Invalid Credit Card No. Must be 16 digits or in the form NNNN NNNN NNNN NNNN.');
cardno.focus();
return false;
}
else 
if (parseInt(matchArr[1],10)==0) {
cardno.value="";
alert("Invalid Credit Card No can't start with 000.");
cardno.focus();
return false;
}
return true;
}



<!-----For Auto Complete----------- -->



function alertSelected()
{ //alert("in alert");
var name=document.getElementById('countrySelectDropdown').value;
//alert(name);
if(name=="na"){
document.getElementById( 'selectedCountry' ).value= "";

}
else{
document.getElementById( 'selectedCountry' ).innerHTML = this.sActiveValue
}
}

function isNumVital(oFormEle,msg)
{
var strString=oFormEle.value;
if(!/\D/.test(strString))
{
<!-----IF NUMBER----------- -->

return true;
}
else if(/^\d+\.\d+$/.test(strString)){
<!-----IF A DECIMAL NUMBER HAVING AN INTEGER ON EITHER SIDE OF THE DOT(.)----------- -->
return true;
}

else{

alert("Please Enter Only Numerics");
oFormEle.value="";
oFormEle.focus();
return false;
}
}

function isweight(oFormEle,msg)
{
var s=oFormEle.value;
if (s>400){
alert("Weight must be less than 400");
oFormEle.focus()
return false;
}
return true;
}
function isheight(oFormEle,msg)
{
var s=oFormEle.value;
if (s>300){
alert("Height must be less than 300");
oFormEle.focus()
return false;
}
return true;
}
function ispulse(oFormEle,msg)
{
var s=oFormEle.value
if (s>120){
alert("Pulse must be less than 120");
oFormEle.focus()
return false;
}
return true;
}
<!-----Phone NO Auto TAb----------- -->
function formatTelNo (telNo)
{
// If it's blank, save yourself some trouble by doing nothing.
if (telNo.value == "") return;



var phone = new String (telNo.value);

phone = phone.substring(0,13);
if (phone.match (".[0-9]{3}.[0-9]{3}-[0-9]{4}") == null)
{

if (phone.match (".[0-9]{2}.[0-9]{3}-[0-9]{4}|" + ".[0-9].[0-9]{3}-[0-9]{4}|" +
".[0-9]{3}.[0-9]{2}-[0-9]{4}|" + ".[0-9]{3}.[0-9]-[0-9]{4}") == null)
{

var phoneNumeric = phoneChar = "", i;

for (i=0;i<phone.length;i++)
{

phoneChar = phone.substr (i,1);
if (!isNaN (phoneChar) && (phoneChar != " ")) phoneNumeric = phoneNumeric + phoneChar;
}

phone = "";

for (i=0;i<phoneNumeric.length;i++)
{
// If it's the first digit, throw in "(" before that.
//if (i == 0) phone = phone + "";
// If you are on the 4th digit, put ") " before that.
if (i == 3) phone = phone + "- ";
// If you are on the 7th digit, insert "-" before that.
if (i == 6) phone = phone + "-";
// Add the digit to the phone charatcer string you are building.
phone = phone + phoneNumeric.substr (i,1)
}
}
}
else
{
// This means the tel no is in proper format. Make sure by replacing the 0th, 4th and 8th character.
phone =  phone.substring (1,3) + "-" + phone.substring (5,8) + "-" + phone.substring(9,13);
}
// So far you are working internally. Refresh the screen with the re-formatted value.
if (phone != telNo.value) telNo.value = phone;
}


function checkTelNo (telNo)
{
if (telNo.value == "") return;
if (telNo.value.match (".[0-9]{3}.[0-9]{3}-[0-9]{4}") == null)
{
if (telNo.value.match ("[0-9]{10}") != null)
formatTelNo (telNo)
}
}

<!-----END Auto Tab----------- -->
<!-----SSN No Format ----------- -->
function fmtssn(oform)
{

re = /\D/g; // remove any characters that are not numbers
socnum=oform.value.replace(re,"")
sslen=socnum.length
if(sslen>3&&sslen<6)
{
ssa=socnum.slice(0,3)
ssb=socnum.slice(3,5)
oform.value=ssa+"-"+ssb
}
else
{
if(sslen>5)
{
ssa=socnum.slice(0,3)
ssb=socnum.slice(3,5)
ssc=socnum.slice(5,9)
oform.value=ssa+"-"+ssb+"-"+ssc
}
else
{oform.value=socnum}
}
}
<!-----END SSN NO Format----------- -->
<!-----ZipCode  Format----------- -->
function fmtzipcode(oform)
{
re = /\D/^g; // remove any characters that are not numbers
socnum=oform.value.replace(re,"")
sslen=socnum.length
if(sslen>4&&sslen<10)
{
ssa=socnum.slice(0,5)
ssb=socnum.slice(5,10)
oform.value=ssa+"-"+ssb
}

else
{oform.value=socnum}
}
<!-----END ZipCode Format----------- -->


