cancel
Showing results for 
Search instead for 
Did you mean: 

I want to enter JS validation in services end date press enter and Check SO.How to do that

Former Member
0 Kudos

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can use the "Link" button (looks like a few links of a chain) to link a text field to a script button, so that pressing enter with the focus in the field will cause the script to be run. That script can then do any validation you need. Is that what you are asking for?

On a practical note, create a script button and build/test the script by pressing the button. Once it is working correctly, then link it to the relevant text field and hide the button (the user doesn't need to actually press it once it is linked, so it does not need to be visible).

Steve.

Former Member
0 Kudos

i want to add JS validation to check whether the date entered is in correct format or not and same with the SO field.

Former Member
0 Kudos

You can do that with a "Calculate in JavaScript" action in the script. Use "Copy Value" first to grab the value from the "services end" field, and call it, say, "enddate". In the JavaScript, you can then access the value as "args.enddate". Do whatever validation you need in JavaScript and set a variable, say "args.valid", accordingly. The following steps of your script can then interact with screen elements to provide feedback as necessary - issue error messages, or whatever you need.

Does that make sense?

Steve.

Former Member
0 Kudos

yea thanks

Former Member
0 Kudos

can you provide the script for date validation?

Former Member
0 Kudos

I am doing but its not working.

Former Member
0 Kudos
Former Member
0 Kudos

Can you provide script as i am not getting don't know where it is not working.

Former Member
0 Kudos

Post the script you have now, and I'll look at what might be going wrong.

Steve.

0 Kudos

hi Roman,


In cases like these, as Steve suggested, posting your script will help others to identify where you are going wrong.

If you want a simple date format validation, you can use Regex. Something like this:

//regex for dd/mm/yyyy

var yourExpression = /^\d{1,2}\/\d{1,2}\/\d{4}$/;

var yourDate = "07/06/1986".

if(yourDate.match(yourExpression)){

  alert("correct date");

}

Regards,

Sushant

Former Member
0 Kudos

Sushant i want tha date to be automatically fetched from the service end field and get checked.

Former Member
0 Kudos

Define "checked". How does Sushant's code above not do what you want? As I said earlier, post what you have so far and how it is not doing what you want, and then maybe we can help...

Steve.

Former Member
0 Kudos

i have posted the script.@Steve please do let me know where i am going wrong

Former Member
0 Kudos

getting this error

Former Member
0 Kudos

var yourDate="   ";for this expression date should be something which is entered by the user in service end field.I want to know how to do that part comparing user entered date with the expression .

Former Member
0 Kudos

Hi Steve,

I have posted the scripts can you have a look and let me know the error in that.

Regards,

Roman

Answers (1)

Answers (1)

Former Member
0 Kudos
Former Member
0 Kudos

The screenshot doesn't show all of the script in step 2 (or does it?). Can you post the script separately so we can see it all?

Steve.

Former Member
0 Kudos

value expression=/^\d{2}[./-]\d{2}[./-]\d{4}$/;

var yourDate=args.enddate;