title: Raising an error in WTForm using jinja2
body: <p>I'm trying to raise an error in Jinja2, in a WTForm, the error should be raised if url input is not validated, but when i submit an invalide url, i get a popup saying "Please enter a url".</p>
  
  <p>how do i pass the default popup and add a custom error message ?</p>
  
  <p>here is the main py:</p>
  
  <pre><code>from datetime import datetime
  from flask import Flask, render_template, url_for, request, redirect,flash
  from logging import DEBUG
  from flask_wtf import FlaskForm
  from wtforms import StringField, PasswordField
  from flask.ext.wtf.html5 import URLField
  from wtforms.validators import DataRequired , url
  
  
  app = Flask(__name__)
  app.logger.setLevel(DEBUG)
  app.config['SECRET_KEY']='{@\x8d\x90\xbf\x89n\x06%`I\xfa(d\xc2\x0e\xfa\xb7&gt;\x81?\x86\x7f\x1e'
  
  
  @app.route('/')
  @app.route('/index')
  
  def index():
      return render_template('base.html')
  
  @app.route('/add', methods=['GET','POST'])
  def add():
      return render_template('add.html')
  
  
  # HERE IS THE LOGIN FORM
  class Login(FlaskForm):
      username = StringField('username')
      password = PasswordField('password')
      url = URLField('url', validators=[DataRequired(),url()])
  
  @app.route('/form', methods=['GET','POST'])
  def form():
      form = Login()
      if form.validate_on_submit():
          url = form.url.data
          return redirect(url_for('index'))
      return render_template('form.html',form = form )
  
  
  if __name__ =='__main__':
      app.run(debug=True)
  </code></pre>
  
  <p>and here is the template:</p>
  
  <pre><code>  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;form&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
   &lt;h1&gt;Hello !&lt;/h1&gt;
   &lt;form method="POST" action="{{url_for('form')}}"&gt;
   {{ form.hidden_tag() }}
   {{ form.csrf_token }}
   {{ form.username.label }}
   {{ form.username }}
   {{ form.password.label }}
   {{ form.password }}
   {{ form.url.label }}
   {{ form.url }}
    {% if form.url.errors %} &lt;p&gt; {{error}}&lt;/p&gt; {% endif %}
   &lt;button type="submit"&gt;Submit&lt;/button&gt;
   &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>