Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Data entry validation
#1
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.
Reply
#2
Hi, you can do in ClientSide with Javascript like this.
Reply
#3
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.
Reply
#4
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.
Reply
#5
(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.
Reply
#6
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;
}
Reply
#7
(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;
Reply
#8
Geremiah, move you code to onBlur event and change this.focus(); to IWCOMPONENTIWCL.focus; ( your component name in UpperCASE plus IWCL ).
Reply
#9
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.
Reply
#10
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)