排除“http"或“;http://www."从angularjs的形式

Exclude "http" or "http://www." from angularjs form

本文关键字:quot http angularjs 排除 www      更新时间:2023-09-26

我搜索如何排除

http

和来自textarea的'www':

            <div id="textareaPart">
                <label for="textarea" class="col-sm-2 control-label">
                    Your message
                    <span class="myForm_error" ng-show="myFormZR.textarea.$error.required">(champ needed)</span>
                    <span class="myForm_textarea" ng-show="myFormZR.textarea.$dirty"> - characters : {{0 + myForm.textarea.length}} / 500</span>
                </label>
                <div class="col-sm-10">
                    <textarea class="form-control" name="textarea" rows="3" required="required" placeholder="500 characters max..." maxlength="500" ng-model="myForm.textarea"></textarea>
                </div>
            </div>

它是n -pattern ?我知道如何允许使用regexp,但如何排除?

您可以这样做:

ng-pattern="/^((?!www|http[s]{0,1}:'/'/www).)*$/";
这将允许以外的所有值,如果它包含:
  • www
  • http://www
  • https://www