How to check a template in submit form

During the given input in the edittext field, it shows an error, if someone sets the embedded format of the IP address of the IP ad, it should look something like this: 000.000.0.000 PLZ help me

In HTML5: -

<div data-role="content"> <form id="form"> <div data-role="fieldcontain"> <label for="ip">IP Address/System Name</label> <input name="ip" id="ip" type="text" pattern="((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$"> </div> <div style="text-align:center;"> <div data-role="button" data-theme="b" data-inline="true" id="button1">Update</div> </div> </div> 
+7
html5
source share
3 answers

To test HTML5 to work in submit, you must put the required attribute in your input fields, you want to test the use of HTML5, and you must submit the form.

You can process the form data submitted through javascript, and if you want to process the submitted data manually, then you must specify data-ajax="false" in the form tag

For your code try

 <div data-role="content"> <form id="form" data-ajax="false"> <div data-role="fieldcontain"> <label for="ip">IP Address/System Name</label> <input name="ip" id="ip" type="text" required pattern="((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$"> </div> <div style="text-align:center;"> <input type="submit" value="Submit button" /> </div> </form> </div> 

And in javascript you can do something like

 $("#form").submit(function(e){ e.preventDefault(); //call your method }); 
+9
source share

One route you can use uses mask.js. In your case, you can force him to enter his data in the correct format, pre-populate '.' characters in the IP address and does not allow the user to enter non-numeric values.

Mask.js

And here is the fiddle - http://jsfiddle.net/QF9Lz/2/

click in the text box, you will see that a formatting mask is displayed, and you can only enter numeric values ​​in the format you specify.

So, as soon as you include mask.js in your head, you can initialize the input mask as follows:

 $(document).ready( function() { $('#ip').mask('999.999.9.999'); }); 
+2
source share

I made this regex for address / mask For example: 10.0.0.0/8

 ((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){3}\/([1-2][0-9]|[0-9]|3[0-2])$ 

if you want to use only regular expression address:

 ((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){3}$ 
-one
source share

All Articles