Remove the validation message after filling the input field.

Remove the validation message after filling the input field.

  

Hi, How do I remove the validation message?


function CheckValidation()
{
     if($('#"+Employee_Address.Id+":text').val() == '') // this is to check if the Input field is empty or not
            {
                  
  $('#"+Employee_Address.Id+"').after('<span style=""background: tomato; color: white; border: 1px solid red; padding: 3px;font-weight: bold;"">Please enter the address.</span>') ; // this will change the current value of the input field    
 
 $('#"+Employee_Address.Id+":text').css('border-color', 'red');


                    
}
      else
            {
                   
                  $('#"+Employee_Address.Id+"').css( 'border-color', 'gray' ); // this will change the color of input field
            
                 $('#"+EmployeeForm.Id+":text').reset();
}


I used this but doesn't work.  How do I clear the validation message once i filled the field.

Hello Sathish,


Could you explain your use case better? Why are you using JavaScript? I believe the built-in OutSystems Platform validations do what you want automatically.

Paulo Ribeiro wrote:

Hello Sathish,


Could you explain your use case better? Why are you using JavaScript? I believe the built-in OutSystems Platform validations do what you want automatically.


Yes It does but I'm learning the functionalities and working of JavaScript and jQuery in Outsystems. So I have been asked to do a generic form validation using Js and jQuery instead of built in outsystems validations.


So can you please help me with this?

Implementing jquery in general is pretty different from implementing the same in out systems.

I'm struggling with the proper syntax for outsystems jquery and JS.

Please help me.  

Hi Satish,

You can define Java Script like this on page:

Script :

function Hide_Validation_Msg(id)
{
$("#"+id.id).removeClass('Not_Valid');
$("#ValidationMessage_"+id.id).css("display","none");
}

Call the script on control as below and you can get result as you expected:


Regards

SK


Sahshi kant Shukla wrote:

Hi Satish,

You can define Java Script like this on page:

Script :

function Hide_Validation_Msg(id)
{
$("#"+id.id).removeClass('Not_Valid');
$("#ValidationMessage_"+id.id).css("display","none");
}

Call the script on control as below and you can get result as you expected:


Regards

SK


Okay.. But where do I place this function ? Inside the else part or separately? 

and the onkeypress properties should be used on input field? or I should use separate label or something for validation message. Previously I made validation message to be displayed rught after the input field.


Can I keep the same logic for using this hide validation function?

If possible can you show it on the oml I attached?