How to validate the value of an input field using mootools (value must be 8) -


hope can give me hint...

i have work mootools , have form. 1 of input fields valid if value number 8. has idea how this?

best regards, dan

if post html of input can better. otherwise:

var element = document.getelement('input'); //or  var element = $('inputid'); //or var element = document.queryselector('input'); 

then use

element.value == 8 or element.get('value') == 8

you can check here mootools docs


as @dimitar pointed out , didn't mention, need listen submit of form , use code check input value.

example:

var form = $('myform');  form.addevent('submit', function (e) {    // attach event form     e.stop();                             // prevent being submited     var input = this.getelement('input'); // input element     if (input.value != 8) {               // verify value         alert('the value not 8');      // inform user         return false;                     // end function     } else this.submit();                 // otherwise, continue submit }); 

demo


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -