如何在此函数中添加另一个条件

时间:2018-05-23 09:27:17

标签: swift

如何为我的函数添加另一个条件,另一个文本字段以及如何使这段代码更简单

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Culture</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<link rel="stylesheet" href="styles.aaf8a2468e47be90b64b.css"></head>
<body>
  <app-root></app-root>

<script type="text/javascript" src="runtime.a66f828dca56eeb90e02.js"></script><script type="text/javascript" src="polyfills.b4daf421c94934f530d4.js"></script><script type="text/javascript" src="main.36d7357da7cc32c08c65.js"></script></body>
</html>

2 个答案:

答案 0 :(得分:1)

下面的代码将更简单,更容易添加任何新条件:

var fs = require('fs');
var path = require('path');
var execSync = require('child_process').execSync;

// Error when no filename argument provided.
if (!process.argv[2]) {
  console.log('\x1b[31mERR!\x1b[0m Trailing filename arg must be provided.');
  process.exit(1);
}

var fileName = process.argv[2];
var srcPath = path.join('sass', fileName) + '.scss';

// Check source .scss file exists.
if (!fs.existsSync(srcPath)) {
  console.log('\x1b[31mERR!\x1b[0m Path cannot be found: %s', srcPath);
  process.exit(1);
}

// Path to node-sass executable in node_modules directory.
var executablePath = path.join('node_modules', '.bin', 'node-sass');

// Destimation path for resultant .css file.
var destPath = path.join('css', fileName) + '.css';

// The command to be invoked.
var cmd = executablePath + ' ' + srcPath + ' ' + destPath + ' -w';

// Execute the command.
execSync(cmd, {
  cwd: process.cwd()
});

答案 1 :(得分:0)

func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool

{
    if textField == textField as? SkyFloatingLabelTextField && (!textField.text.containsString("@") || textField.text.characters.count    < 3 )
    {
            floatingLabelTextField.errorMessage = "Invalid email"
    }
    else
    {
        floatingLabelTextField.errorMessage = ""
    }

return true
}

您可以先检查文本字段是否为您选择的文本字段,并且在相同条件下您还可以检查电子邮件验证。