client script onsubmit
						
					
					
				
			
		
	
			
	
	
	
	
	
Options
			
				
					
	
			
		
	- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
05-06-2025 02:15 PM
1st:
function onSubmit() {
   //Type appropriate comment here, and begin script below
   var getJoiningDate=g_form.getValue('u_joining_date'); //get the value of the Joining Date
    var todayDate= new Date();  // Create a Date object for today's date
   var getJoiningDateFormat=new Date(getJoiningDate); //Convert the Joining Date to Date obj
   if(getJoiningDateFormat>todayDate)//Check if the Joining Date is greater than todays date
   {
    g_form.addErrorMessage('Joining date date cannot be in future');
    g_form.clearValue('u_joining_date');
    return false;
   }
}
2nd :
function onSubmit() {
    //Type appropriate comment here, and begin script below
    var joiningdate = g_form.getValue('u_joining_date');
    var todaydate = new Date();
    var joindateformat = new Date(joiningdate);
    if (joindateformat>todaydate)
    {
        g_form.showFieldMsg('u_joining_date','Joining date date cannot be in future','error');
        g_form.clearValue('u_joining_date');
        return false;
    }
}
1st one is working fine but not the second one is partially working why? especially this g_form.showFieldMsg('u_joining_date','Joining date date cannot be in future','error');  this error is not showing below the field
		2 REPLIES 2
	
		
		
			
			
			
					
	
			Options
			
				
					
	
			
		
	- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
05-08-2025 11:40 AM
Options
			
				
					
	
			
		
	- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
05-08-2025 12:05 PM
Hi @patilabhilash ,
That's because the order of showFieldMsg and clearValue methods
first use
clearValue and then the showFieldMsg and check
 g_form.clearValue('u_joining_date');
 g_form.showFieldMsg('u_joining_date', 'Joining date date cannot be in future', 'error');
coming the date validation refer the already solved problems in case of yours is not working
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
