PDA

View Full Version : [CLOSED] TagField : Validate tags



matrixwebtech
Dec 31, 2014, 8:08 AM
I think this is not directly related to Ext.net . I have a tagfield with tag bellow

BasicSalary+ConvenceAllowance+HouseRentAllowance+ I like to validate this on a buttonclick.

the string can be dynamic ,like more value separate with operator(operators ).Is it possible to validate with RegExp?please help me to go right direction.

The tagfield invalid for bellow scenario

1. +BasicSalary+ConvenceAllowance+HouseRentAllowance
2. BasicSalary+ConvenceAllowance+HouseRentAllowance+
3 BasicSalary-+ConvenceAllowance--HouseRentAllowance

so logic is
1. tag not start or end with any operator (+,-,*,/,%)
2. one operand and one operator , should not two operator without operand.
how do I do this.

Sample Code


@{
Layout = null;
var X = Html.X();
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script>

var validateTag = function () {
}
var addtag = function () {
App.tag.addTag({ text: 'BasicSalary', value: 1 });
App.tag.addTag({ text: '+', value: 2 });
App.tag.addTag({ text: 'ConvenceAllowance', value: 3 });
App.tag.addTag({ text: '-', value: 4 });
App.tag.addTag({ text: 'HouseRentAllowance', value: 5 });

}

</script>
</head>
<body>
<div>


@X.ResourceManager()
@(X.TagField()
.ID("tag")
.HideSelected(true)
.Width(800)

.HideTrigger(true)
.Editable(true)
.TagLabelConfig(X.TagLabel().AllowDuplicates(true) )
.MultiSelect(true)

)
@(X.Button().Text("Click")
.Listeners(l =>
{
l.Click.Handler = "validateTag()";
l.AfterRender.Handler = "addtag()";
})
)
</div>
</body>
</html>

Daniil
Dec 31, 2014, 2:53 PM
Hi @matrixwebtech,

Yes, I think it is possible to validate it using regular expressions.

This might help you.
http://stackoverflow.com/questions/899422/regular-expression-for-a-string-that-does-not-start-with-a-sequence