- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 07:13 AM
Would it be best to create a String field and somehow put restrictions on that? If so, what type of restrictions would I apply?
Or is there a way to use the existing Date field to do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 08:54 AM
var reg = /(19[6789]\d|20[01]\d)/ ;
var ans = g_form.getValue('fieldname');
if(!reg.test(ans))
{
alert('Please enter valid year');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 07:32 AM
Better create a string field and create a on change client script to validate the data using regular expression.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 07:46 AM
I am thinking this is the way to go. I found a regular expression that would work but I'm unsure how to use that regular expression within script... how would I format that?
The reg ex is:
(19[6789]\d|20[01]\d)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 08:03 AM
Hi Tess,
To use the regex, use a line similar to the following:
var answer = /(19[6789]\d|20[01]\d)/.test(g_form.getValue('filename') +'');
The answer variable will contain true or false depending on whether or not the field value matches the regex.
Edit: Changed "reggae" to "regex", not even sure if that was autocorrect or me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 08:18 AM
Write onchange script use below code.
checkExpire();
function checkExpire()
{
var res = 'ok';
var re=/^(20|19)\d\d+$/; // This reg expression can valid only if the year start with 19 or 20
var expiredate='19163'; //Ex: it can tale 1900,etc 2012etc but it wont allow to enter 1890and 2121
if(!re.test(expiredate))
{
alert('Please enter valid year');
}
else if(expiredate.length >4 || expiredate.length<4)
{
alert('Please enter only 4 digits year');
}
else
{
alert('perfect');
}
}
Regards,
Harish.