Mobile number validation

chadhini wrote on Friday, October 09, 2015:

Hi

I have been trying to use the registration form with proper validation and as I go I find that some of the validation like - mobile number length and input characters are not getting validated by the provided javascript function - checkPhone() and checkLength(). Can someone look into this and clear the doubt.

I tried changing the input tag for mobile number with attribute minlength , to limit the input to 10 digits but no success.

if ($field_id_esc=='phone_cell')
	{

	echo "<input type='text'" .
      " name='form_$field_id_esc'" .
      " id='form_$field_id_esc' minlength=10" .
      " size='$fldlength' $string_maxlength" .
      " required " .
      " title='$description'" .
      " value='$currescaped'";

	}

and the js function -

function validate(f) {
  var errMsgs = new Array();
  <?php generate_layout_validation('DEM'); ?>
  <?php if($GLOBALS['erx_enable']){ ?>
  alertMsg='';
  
  for(i=0;i<f.length;i++){
	
    if(f[i].type=='text' && f[i].value)
    {
      if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
      {
        alertMsg += checkLength(f[i].name,f[i].value,35);
        alertMsg += checkUsername(f[i].name,f[i].value);
      }
      else if(f[i].name == 'form_street' || f[i].name == 'form_city')
      {
        alertMsg += checkLength(f[i].name,f[i].value,35);
        alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
      }
      else if(f[i].name == 'form_phone_cell')
      {
       alertMsg += checkPhone(f[i].name,f[i].value);
	   //alertMsg += checkLength(f[i].name,f[i].value,10);  // for checking the length 
      }
    }
  }

visolveemr wrote on Saturday, October 10, 2015:

Hello Chandani

From the Java script function validate() you mentioned above it seems, it will execute only if the $GLOBALS[‘erx_enable’] is set. This can be enabled by checking the** ‘Enable NewCrop eRx Service’** checkbox under ‘Administration->Globals->Connectors’ screen.

Thanks
OpenEMR Customization/Support Team,
ViSolve Inc
services@visolve.com | Phone: 408-850-2243
Demo’s @ ViSolve Demo Library

tmccormi wrote on Monday, October 12, 2015:

That would be a bad idea unless you are using NewCrop eRX. Better to change the wrapper to drop the dependency.

visolveemr wrote on Tuesday, October 13, 2015:

Yes Tony
This dependency is also checked for the field validations in User creation, Facility Creation and Patient creations. It would be better to remove this dependency in these validations.

Thanks
OpenEMR Customization/Support Team,
ViSolve Inc
services@visolve.com | Phone: 408-850-2243
Demo’s @ ViSolve Demo Library

tmccormi wrote on Tuesday, October 13, 2015:

Some of the checks like 35 char max length only apply to NewCrop, but others could be more general, for sure.

OpenEMR lacks a lot in data entry field validation

chadhini wrote on Friday, October 16, 2015:

Thank you ViSolve

I enabled and it worked, alternatively before when I was trying to make this function work, I added a ‘not’ to - if($GLOBALS[‘erx_enable’] condition and it didnt work.
Looks like I missed on an obvious thing.