我有3个文本框:textbox1,textbox2,textbox3。用户只允许在一个文本框中填写信息。
before_deploy:
- export ELASTIC_BEANSTALK_LABEL=$(git tag --contains)
- git clone -b master https://github.com/jasny/dpl.git /tmp/dpl
- (cd /tmp/dpl && gem build dpl.gemspec && cp *.gem "$TRAVIS_BUILD_DIR")
deploy:
provider: elasticbeanstalk
edge: local
access_key_id: ...
secret_access_key:
secure: ...
region: eu-west-1
app: dms
env: dms-travis-test
bucket_name: elasticbeanstalk-eu-west-1-930677074220
bucket_path: dms
on:
branch: travis-deploy
还有另一种验证这些文本框的方法吗?我希望更短版本。
答案 0 :(得分:0)
怎么样:
var state1 = string.IsNullOrWhiteSpace(textbox1.Text);
var state2 = string.IsNullOrWhiteSpace(textbox2.Text);
var state3 = string.IsNullOrWhiteSpace(textbox3.Text);
if (!(state1 || state2 || state3))
{
return "Please Enter a Search Parameter";
}
if (!(state1 ^ state2 ^ state3))
{
return "Please only enter one Criteria";
}
if (state1)
{
return "Something else";
}
if (state2)
{
return "Something there";
}
return "Something here";