Atozed Forums
Data entry validation - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: Data entry validation (/thread-610.html)



Data entry validation - geremiah - 08-24-2018

How can be done a data validation for the user input in a db aware control ?
Can be used one of the control events ?
Must be used Javascript ?
Thank you.


RE: Data entry validation - Jose Nilton Pace - 08-25-2018

Hi, you can do in ClientSide with Javascript like this.


RE: Data entry validation - geremiah - 08-25-2018

I'm using some validation code in the onChange event, but if the user input is not validated how can i give back to focus to the control ? Using the controlname.focus() isn't working.


RE: Data entry validation - Jose Nilton Pace - 08-25-2018

I don't understand very well are you trying to do. In asyncchange the component don't lose focus. In delphi side component.SetFocus; works. in JavaScript $("component").focus(); works too.


RE: Data entry validation - geremiah - 08-26-2018

(08-25-2018, 05:51 PM)José Nilton Pace Wrote: I don't understand very well are you trying to do. In asyncchange the component don't lose focus. In delphi side component.SetFocus; works. in JavaScript $("component").focus(); works too.

I'm using the scriptevents OnChange event, in this i check  the user input, if it isn't valid i show an alert with an error message and i would give back the focus to the same control using the $("component").focus(); but this isn't working, the focus go always to the next control.


RE: Data entry validation - Jose Nilton Pace - 08-26-2018

Geremiah, i have not seen your code, so I'm working with assumptions and i have an idea for you. In your ScriptEvents when it isn't valid put this code:

if (isn't valid)
{
  this.focus(); /* or IWCOMPONENTIWCL.focus(); */
  return false;
}else{
  return true;
}


RE: Data entry validation - geremiah - 08-26-2018

(08-26-2018, 02:18 PM)José Nilton Pace Wrote: Geremiah, i have not seen your code, so I'm working with assumptions and i have an idea for you. In your ScriptEvents when it isn't valid put this code:

if (isn't valid)
{
  this.focus(); /* or IWCOMPONENTIWCL.focus(); */
  return false;
}else{
  return true;
}

More or less the same but it doesn't work

var uid_len = this.value.length;
if (uid_len != 11 )
{
alert("Lunghezza Partita IVA errata !! ");
this.focus();
return false;
}
return true;


RE: Data entry validation - Jose Nilton Pace - 08-26-2018

Geremiah, move you code to onBlur event and change this.focus(); to IWCOMPONENTIWCL.focus; ( your component name in UpperCASE plus IWCL ).


RE: Data entry validation - geremiah - 08-26-2018

Thank you for your suggestion.
I've tested with Internet Explorer and Microsoft Edge and it runs well, on Firefox quantum still not working, now i'm going to test on Chrome and Safari.


RE: Data entry validation - geremiah - 08-26-2018

I've finished the tests on all the browsers i have.
I've made a little modify to the focus code as follow:

setTimeout(function(){TIWDBADVEDIT1IWCL.focus();}, 1);

In this way all is working fine on all the browsers.
Thank you very much Jose, without your help I would never have solved the problem.