作成日: 2018/04/06 最終更新日: 2018/04/06
文書種別
使用方法
詳細
TextCellTypeでは、MaxLengthに指定した数を超える文字数を入力することはできません。
MaxLengthを超える文字数の入力を可能とし、且つその場合にエラーメッセージ表示するには、TextCellTypeのValidatorsプロパティに標準のCustomValidatorを使用してください。
◎サンプルコード(VB)
◎サンプルコード(C#)
MaxLengthを超える文字数の入力を可能とし、且つその場合にエラーメッセージ表示するには、TextCellTypeのValidatorsプロパティに標準のCustomValidatorを使用してください。
◎サンプルコード(VB)
------------------------
Webフォームクラス
------------------------
Dim cValidator As CustomValidator = New CustomValidator
cValidator.ValidateEmptyText = False
cValidator.ClientValidationFunction = "ClientValidate"
cValidator.ErrorMessage = "5文字以内"
Dim tCell1 As FarPoint.Web.Spread.TextCellType = New FarPoint.Web.Spread.TextCellType
tCell1.Validators.Add(cValidator)
FpSpread1.ActiveSheetView.Columns(0).CellType = tCell1
------------------------
クライアント側スクリプト
------------------------
<script type="text/javascript">
function ClientValidate(source, arguments) {
if (arguments.Value.length <= 5) {
arguments.IsValid = true;
} else {
arguments.IsValid = false;
}
}
</script>
Webフォームクラス
------------------------
Dim cValidator As CustomValidator = New CustomValidator
cValidator.ValidateEmptyText = False
cValidator.ClientValidationFunction = "ClientValidate"
cValidator.ErrorMessage = "5文字以内"
Dim tCell1 As FarPoint.Web.Spread.TextCellType = New FarPoint.Web.Spread.TextCellType
tCell1.Validators.Add(cValidator)
FpSpread1.ActiveSheetView.Columns(0).CellType = tCell1
------------------------
クライアント側スクリプト
------------------------
<script type="text/javascript">
function ClientValidate(source, arguments) {
if (arguments.Value.length <= 5) {
arguments.IsValid = true;
} else {
arguments.IsValid = false;
}
}
</script>
◎サンプルコード(C#)
-------------------------------
Webフォームクラス
-------------------------------
CustomValidator cValidator = new CustomValidator();
cValidator.ValidateEmptyText = false;
cValidator.ClientValidationFunction = "ClientValidate";
cValidator.ErrorMessage = "5文字以内";
FarPoint.Web.Spread.TextCellType tCell1 = new FarPoint.Web.Spread.TextCellType();
tCell1.Validators.Add(cValidator);
FpSpread1.ActiveSheetView.Columns[0].CellType = tCell1;
------------------------
クライアント側スクリプト
------------------------
※VBのサンプルコードと同様
Webフォームクラス
-------------------------------
CustomValidator cValidator = new CustomValidator();
cValidator.ValidateEmptyText = false;
cValidator.ClientValidationFunction = "ClientValidate";
cValidator.ErrorMessage = "5文字以内";
FarPoint.Web.Spread.TextCellType tCell1 = new FarPoint.Web.Spread.TextCellType();
tCell1.Validators.Add(cValidator);
FpSpread1.ActiveSheetView.Columns[0].CellType = tCell1;
------------------------
クライアント側スクリプト
------------------------
※VBのサンプルコードと同様
旧文書番号
41731