Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to validate this form with Javascript?

Featured Replies

Hi,

 

Check this code out:

 

<form class="form-inline">
<div class="form-group">
<label class="sr-only" for="registration">Registreringsnummer</label>
<input type="text" class="form-control">
</div>
<div class="form-group">
<label class="sr-only" for="dittpersonnummer">Ditt personnummer (11 siffer)</label>
<input type="password" class="form-control" placeholder="DDMMAAnnnnn">
</div>
<div class="form-group">
<select class="form-control">
<option>Velg</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
<div class="form-group">

<button type="submit" class="button-2">Neste</button>
</div>
</form>

 

I have a form going across horizontally formatted and everything, but I am new to this and I am wondering how would you validate this? I am so confused with the form group, form inline etc. Some of you may say I should know as I coded it but I grabbed it off Bootstrap to assist me in the making.

 

Thanks.

  • Author

If you guys are gonna do this in CodePen this is the CSS just so you can see it properly.

 

 

.form-control {
font-size: 14px;
font-weight: normal;
line-height: 1;
color: #555;
background-color: #eee;
border: 1px solid #ccc;
border-radius: 4px;
padding-top: 6px;
padding-right: 12px;
padding-bottom: 6px;
padding-left: 12px;
}

.form-inline {
width: 100%;
}

.form-group {
display: inline-block;
margin-bottom: 0;
vertical-align: middle;
padding-left: 1%;
padding-right: 1%;
}



.sr-only {
display: block;
padding: .2em .6em .3em;
font-size: 75%;
line-height: 1;
white-space: nowrap;
vertical-align: baseline;
border-radius: .25em;
}

 

More of the HTML below:

 

<div class="div-box-5">
<div class="bottom-centre-text"><h2>Kjøp bilforsikring i to enkle trinn</h2>




<form class="form-inline">
<div class="form-group">
<label class="sr-only" for="registration">Registreringsnummer</label>
<input type="text" class="form-control">
</div>
<div class="form-group">
<label class="sr-only" for="dittpersonnummer">Ditt personnummer (11 siffer)</label>
<input type="password" class="form-control" placeholder="DDMMAAnnnnn">
</div>
<div class="form-group">
<select class="form-control">
<option>Velg</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
<div class="form-group">

<button type="submit" class="button-2">Neste</button>
</div>
</form>



</div>



</div>

You are planning on validating server side too right? In any case it would probably do you good to learn JavaScript because it sounds like you are wanting us to do it for you. Please excuse if I am wrong.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.