ajax - grails remoteField javascript -


i'm having trouble returning value view decides if submit button should selectable or not. i'm checking value of accnbr against api call returns json. simple want not if user found or not.

a snippet within form on view - here account number input:

<g:remotefield paramname="accnbr" action="validatecustomer" update="[failure: 'error']" bean="${accnbrinstance}"  required="" size='40' name="accnbr" value="${accnbr}" data-trigger="change" data-required="true" data-regexp="[0-9]{12}" data-regexp-message="this field requires valid account number of 12 digits"/> 

then have js (which think has errors:

function accountnoerror(){      if($('#accountvalid').html().value = "not found"){         $('#submit').attr("disabled", true);         $('#clear_btn').show();     }else{         $('#submit').attr("disabled", true);     }  } 

and controller function:

def validatecustomer() {      def accountno = params.accnbr     //def accountno = "621137093178"     def accountvalid      if(accountno.length() == 12){         def http = new httpbuilder('https://my.api.call/' + accountno)         http.auth.basic ('username','password')         http.request(get, contenttype.json) { req ->             response.success = { resp, json ->                 assert resp.statusline.statuscode == 200                 accountvalid = json                 print("json is: " + json)                 println("valid account")             }         }     }else {         accountvalid = "not found"         println("invalid account")     }      return accountvalid } 

in jquery have if...else statement.

in if disable submit button:

$('#submit').attr("disabled", true); 

and in else disable submit button:

$('#submit').attr("disabled", true); 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -