- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2016 05:01 AM
Looking for field data validation
1. It should start begin with an alpha character
2. Can only be (a-z) lower case
3.(0-9) numbers
4. "-" (hyphen) character.
Please also suggest if it should work on Onload , On change or onsubmit.
There is a field of a catalog named hostname(single text line) on which this validation is required.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2016 11:28 PM
Try below:-
var regexp=/^[a-z]{1}[a-z0-9-]*$/;
if(!regexp.test(newValue)){
alert('Please enter valid characters");
g_form.setValue('ur_name','');
}
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
Thanks,
Deepa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2016 11:38 PM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var regexp = /^[a-z]{1}[a-z0-9-]*$/;
if(!regexp.test(newValue)){
alert("Please enter valid characters.It should start with lowercase alpha character, include [0-9] and hyphen");
g_form.setValue('host_name', '');
}
}
PS: Its working correctly but just wanted to know why that warning is coming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2016 11:56 PM
M not getting any warning message if I save the same code...can you try refreshing and see...code is fine..
It might be showing old error.
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
Thanks,
Deepa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2016 12:32 AM
Yes its getting saved and not showing any warning . It only shows warning if I click check syntax button situated above where we write code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2016 08:13 AM
Aastha,
Write an onChnage client script on the hostname variable add this in your script for validation
if(/^[a-z]{1}[a-z0-9-]*$/g.test(newValue)){
//do nothing
}
else{
alert('Please enter valid characters");
g_form.setValue('hostname','');
}
Thanks,
Abhinay
Please mark Helpful, Like, or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2016 11:27 PM
Its giving error : Unescaped -
Then I tried using /^[a-z]{1}[a-z0-9"-"]*$/ still its not working for hyphen.
If I use hyphen then also its giving me alert message.